Beispiel #1
0
    private void onTick(int count)
    {
        if (bundlePool.Count <= 0)
        {
            return;
        }
        var ier = bundlePool.GetEnumerator();

        removeLst.Clear();
        while (ier.MoveNext())
        {
            if (ier.Current.Value.AType == E_AssetType.Atlas)
            {
                if (!ier.Current.Value.isAlive())
                {
                    removeLst.Add(ier.Current.Key);
                }
            }
        }
        for (int i = 0; i < removeLst.Count; i++)
        {
            TBundle tb = bundlePool[removeLst[i]];
            bundlePool.Remove(removeLst[i]);
            tb.onDispose();
        }
    }
Beispiel #2
0
 private void setSpSprite(Image img, string name, SpriteRenderer renderer = null)
 {
     if (atlasCfg.ContainsKey(name))
     {
         string bundleName = atlasCfg[name];
         if (AssetMgr.isHave(bundleName))
         {
             TBundle tb = AssetMgr.getBundle(bundleName);
             if (img != null)
             {
                 img.sprite = tb.Ab.LoadAsset <Sprite>(name);
             }
             if (renderer != null)
             {
                 renderer.sprite = tb.Ab.LoadAsset <Sprite>(name);
             }
         }
         else
         {
             //需要加载ab
             index++;
             SpriteTask spTask = new SpriteTask(index, name, bundleName, img, renderer);
             dictTask.Add(index, spTask);
         }
     }
     else
     {
         Debug.LogError("请导出图集配置");
     }
 }
Beispiel #3
0
 //添加一个Bundle引用
 private void addBundleRef(string url, int count = 1)
 {
     url = getName(url);
     if (bundlePool.ContainsKey(url))
     {
         TBundle tab = bundlePool[url];
         tab.addRefCount(count);
     }
 }
Beispiel #4
0
 //添加一个ab
 private void addAssetBundle(string url, AssetBundle ab)
 {
     url = getName(url);
     if (!bundlePool.ContainsKey(url))
     {
         TBundle tab = new TBundle(url, ab);
         bundlePool.Add(url, tab);
     }
 }
Beispiel #5
0
 //释放一个ab
 private void disposeAssetBundle(string url)
 {
     url = getName(url);
     if (bundlePool.ContainsKey(url))
     {
         TBundle tb = bundlePool[url];
         bundlePool.Remove(url);
         tb.onDispose();
     }
 }
Beispiel #6
0
    public void UpdateBundle(string code, string nameKey, string iconPath, string descKey)
    {
        TBundle tBundle = Get <TBundle>(code);

        if (tBundle == null)
        {
            Debug.LogError("Fail to find generic bundle item with " + code);
        }
        else
        {
            tBundle.name    = nameKey;
            tBundle.comment = descKey;
            qIconReq.Enqueue(new IconReq(code, iconPath));
        }
    }
Beispiel #7
0
 private void onLoaderFinish(string result, bool isSucc, TBundle tb)
 {
     if (isSucc)
     {
         Sprite sprite = tb.Ab.LoadAsset <Sprite>(name);
         if (img != null)
         {
             img.sprite = sprite;
         }
         if (renderer != null)
         {
             renderer.sprite = sprite;
         }
     }
 }
Beispiel #8
0
 private void onLoaderFinish(string result, bool isSucc, TBundle tb)
 {
     if (isSucc)
     {
         AudioClip clip = tb.Ab.LoadAsset <AudioClip>(name);
         for (int i = 0; i < loadHandler.Count; i++)
         {
             loadHandler[i].Invoke(clip);
         }
     }
     else
     {
         Debug.LogError("加载audio失败 path " + this.path);
     }
 }
Beispiel #9
0
 private void onLoaderFinish(string result, bool isSucc, TBundle tb)
 {
     if (isSucc)
     {
         UnityEngine.Object obj  = tb.Ab.LoadAsset(getAbName(url));
         GameObject         temp = GameObject.Instantiate(obj) as GameObject;
         temp.name = temp.name.Replace("(Clone)", "");
         temp.transform.SetParent(root);
         temp.transform.localPosition = new Vector3(2000, 2000, 2000);
         tempObj         = temp.AddComponent <PoolObj>();
         tempObj.Obj     = temp;
         tempObj.pType   = pType;
         tempObj.url     = url;
         tempObj.depends = this.depends;
         tempObj.onInit();
         for (int i = 0; i < loadHandler.Count; i++)
         {
             GameObject go = getInsObj();
             loadHandler[i](go);
         }
         loadHandler.Clear();
     }
 }
Beispiel #10
0
 /// <summary>
 /// 加载clip
 /// </summary>
 /// <param name="path"></param>
 /// <param name="callBack"></param>
 private void loadClip(string path, Action <AudioClip> callBack)
 {
     if (AssetMgr.isHave(path))
     {
         TBundle tb = AssetMgr.getBundle(path);
         if (callBack != null)
         {
             callBack(tb.Ab.LoadAsset <AudioClip>(getAudioName(path)));
         }
     }
     else
     {
         //需要加载ab
         if (tasks.ContainsKey(path))
         {
             tasks[path].addHandler(callBack);
         }
         else
         {
             AudioTask task = new AudioTask(path, callBack);
             tasks.Add(path, task);
         }
     }
 }
Beispiel #11
0
 private int DoBundle(TBundle tBundle)
 {
     return(0);
 }
Beispiel #12
0
 public static CBResult <TBundle <T> > tBundlePositive <T>(TBundleFunc <T> func, TBundle <T> o)
 {
     o = func(o);
     return(new CBResult <TBundle <T> >()
     {
         breakloop = o.breakEvent,
         ans = o
     });
 }
Beispiel #13
0
 public void InitDialog(Item _item, TBundle _bundle)
 {
     item    = _item;
     tBundle = _bundle;
 }