赞
踩
引用计数的使用5
public class AssetBundleRes : Res
{
public AssetBundle AssetBundle
{
get { return Asset as AssetBundle; }
set { Asset = value; }
}
private string mAssetPath;
public AssetBundleRes(string assetPath)
{
mAssetPath = assetPath;
Name = assetPath;
}
public override bool LoadSync()
{
return AssetBundle = AssetBundle.LoadFromFile(mAssetPath);
}
public override void LoadAsync(Action<Res> onLoaded)
{
var resRequest = AssetBundle.LoadFromFileAsync(mAssetPath);
resRequest.completed += operation =>
{
AssetBundle = resRequest.assetBundle;
onLoaded(this);
};
}
protected override void OnReleaseRes()
{
if (AssetBundle != null)
{
AssetBundle.Unload(true);
AssetBundle = null;
}
ResMgr.Instance.SharedLoadedReses.Remove(this);
}
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。