Exemplo n.º 1
0
 //销毁池
 public virtual void onDispose()
 {
     LoadItemMgr.remove(resName, loadFinish);
     if (cacheLst != null)
     {
         int count = cacheLst.Count;
         //释放静态引用
         if (count > 0)
         {
             for (int i = 0; i < deps.Count; i++)
             {
                 AssetMgr.subRef(deps[i], count);
             }
             AssetMgr.subRef(resName, count);
         }
         //释放动态引用
         for (int i = 0; i < cacheLst.Count; i++)
         {
             PoolObj po = cacheLst[i].GetComponent <PoolObj>();
             if (po.getDepsNum() > 0)
             {
                 List <string> dyDeps = po.getDeps();
                 for (int j = 0; j < dyDeps.Count; j++)
                 {
                     AssetMgr.subRef(dyDeps[i]);
                 }
             }
         }
         //销毁gameobject
         for (int i = 0; i < cacheLst.Count; i++)
         {
             GameObject.Destroy(cacheLst[i]);
         }
         cacheLst.Clear();
         cacheLst = null;
     }
     if (deps != null)
     {
         deps.Clear();
         deps = null;
     }
     GameObject.Destroy(this.poolRoot.gameObject);
 }
Exemplo n.º 2
0
 //释放引用
 public static void subRef(string resName, int count = 1)
 {
     AssetMgr.subRef(resName, count);
 }