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); } } }
/// <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); } }
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); } } } }