Example #1
0
    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);
        }
    }
Example #2
0
 public bool RemvBundle(XAssetBundle bundle)
 {
     if (bundle_cnt > 0 && ContainsBundle(bundle.hash))
     {
         --bundle_cnt;
         bundles.Remove(bundle);
         return(true);
     }
     return(false);
 }
Example #3
0
 public bool CacheBundle(XAssetBundle bundle)
 {
     if (bundles == null)
     {
         bundles = new List <XAssetBundle>();
     }
     if (bundle != null && !ContainsBundle(bundle.hash))
     {
         bundles.Add(bundle);
         bundle_cnt++;
         return(true);
     }
     return(false);
 }
Example #4
0
 public XAssetBundle GetBundle(AssetBundleData data)
 {
     if (bundle_cnt > 0)
     {
         for (int i = 0; i < bundle_cnt; i++)
         {
             if (bundles[i].hash == data.hash)
             {
                 XAssetBundle b = bundles[i];
                 b.OnReuse();
                 return(b);
             }
         }
     }
     return(new XAssetBundle(data));
 }
Example #5
0
    private UnityEngine.Object LoadFromBundle(AssetBundleData data)
    {
        XAssetBundle bundle = ab.GetBundle(data);

        return(bundle.LoadAsset(data.loadName));
    }