private UnityEngine.Object LoadAsset() { uint hash = data.hash; if (ab.IsCached(hash)) { // //被依赖的bundle要重新load 不能直接从cache列表取 否则最终的prefab会缺少依赖的资源 // //为了避免内存里有多个对象 要把之前cache的卸载掉 // //直接Unload时,若依然有物体用该图,那么物体就变全黑 // UnityEngine.Object obj = ABManager.singleton.GetCache(hash); // //XResourceMgr.UnloadAsset(obj); // obj = LoadFromBundle(data); // ABManager.singleton.CacheObject(hash, obj); // return obj; var asset = ab.GetCache(hash); asset.ref_cnt++; return(asset.obt); } else { XAssetBundle bundle = ab.GetBundle(data); UnityEngine.Object obj = bundle.LoadAsset(data.loadName); ab.CacheObject(hash, obj, isCloneAsset); return(obj); } }
private UnityEngine.Object LoadFromBundle(AssetBundleData data) { XAssetBundle bundle = ab.GetBundle(data); return(bundle.LoadAsset(data.loadName)); }