Example #1
0
 public override void getObj(string name, Action <Sprite, string> callBack, bool forceRemove = false)
 {
     //bundle池有
     if (AssetMgr.has(resName))
     {
         PackAsset pab = AssetMgr.get(resName);
         pab.getObj <Sprite>(name, callBack);
     }
     else
     {
         if (forceRemove)
         {
             Debug.LogError("加载资源失败 path " + resName);
         }
         else
         {
             if (!handler.ContainsKey(name))
             {
                 handler.Add(name, new List <Action <Sprite, string> >());
             }
             handler[name].Add(callBack);
             LoadItemMgr.add(resName, resPath, loadFinish);
         }
     }
 }
Example #2
0
 /// <summary>
 /// 移除一个正在加载的任务
 /// 上层的创建一个gameobject的时候 很有可能调了创建 马上又销毁(这个时候unload掉)
 /// </summary>
 /// <param name="resName"></param>
 /// <param name="callBack"></param>
 public void unLoad(string resName, Action <GameObject> callBack)
 {
     resName = resName.ToLower();
     if (pools.ContainsKey(resName))
     {
         pools[resName].removeHandler(callBack);
     }
     if (AssetMgr.has(resName))
     {
         PackAsset pka = AssetMgr.get(resName);
         pka.remove(callBack);
     }
 }
Example #3
0
 //预加载
 public virtual void preLoad(Action <string> preLoad, int preLoadCount = 0)
 {
     this.preLoadCount   = preLoadCount;
     this.preLoadHandler = preLoad;
     if (!AssetMgr.has(resName))
     {
         if (cacheLst != null && cacheLst.Count > 0)
         {
             Debug.LogError("预创建错误 gameobject池子有缓存 但是assetbundle已经不存在(可能造成预设资源丢失)");
         }
         LoadItemMgr.add(resName, resPath, onPerCreate);
     }
     else
     {
         onPerCreate(resName);
     }
 }
Example #4
0
 public virtual void getObj(Action <GameObject> callBack, bool forceRemove = false, int count = 0)
 {
     if (cacheLst.Count > count)
     {
         //缓存池有
         GameObject obj = cacheLst[0];
         cacheLst.RemoveAt(0);
         obj.transform.SetParent(null);
         callBack(obj);
     }
     else
     {
         //bundle池有
         if (AssetMgr.has(resName))
         {
             PackAsset pab = AssetMgr.get(resName);
             pab.getObj(callBack);
         }
         else
         {
             if (forceRemove)
             {
                 Debug.LogError("加载资源失败 path " + resName);
             }
             else
             {
                 //都没有 先load ab
                 if (handler == null)
                 {
                     handler = new List <Action <GameObject> >();
                 }
                 handler.Add(callBack);
                 LoadItemMgr.add(resName, resPath, loadFinish);
             }
         }
     }
 }
Example #5
0
    void doCheck(string name)
    {
        //1 ab池子是否已经有了
        bool hasAB = AssetMgr.has(name);

        if (hasAB)
        {
            AssetMgr.addRef(name);
            taskFinish("");
        }
        else
        {
            //如果加载任务里面有此任务 则加回调
            if (LoadMgr.hasTask(name))
            {
                LoadMgr.addHandler(name, taskFinish);
            }
            else
            {
                string resPath = Path.Combine(Define.abPre, name).ToLower();
                LoadMgr.doLoad(name, resPath, taskFinish);
            }
        }
    }