private void OnResourceDone(Resource res)
 {
     if (res.isSucc)
     {
         List <ResourceHandler> succList;
         _succCallbacks.TryGetValue(res, out succList);
         _succCallbacks.Remove(res);
         if (succList != null)
         {
             for (int i = 0; i < succList.Count; i++)
             {
                 succList[i].Invoke(res);
             }
             succList.Clear();
         }
         res.Release();
     }
     else
     {
         //失败的话,将资源先移除掉
         if (res.refCount > 1)
         {
             CLog.LogError("DestroyResource[resPath=" + res.path + "],RefCount>1.");
         }
         else
         {
             _mapRes.Remove(GetCacheResourceKey(res.path));
         }
         List <ResourceHandler> failList;
         _failCallbacks.TryGetValue(res, out failList);
         _failCallbacks.Remove(res);
         if (failList != null)
         {
             for (int i = 0; i < failList.Count; i++)
             {
                 failList[i].Invoke(res);
             }
             failList.Clear();
         }
         res.Release();
         if (res.refCount <= 0)
         {
             res.DestroyResource();
         }
     }
 }
 public void RemoveWaitLoadingRes(Resource res)
 {
     if (_resLoader.RemoveWaitingLoadingRes(res))
     {
         RemoveAllListener(res);
         if (_mapRes.Remove(res.path))
         {
             res.Release();
         }
     }
 }
Example #3
0
 static int Release(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         Launch.Resource obj = (Launch.Resource)ToLua.CheckObject(L, 1, typeof(Launch.Resource));
         obj.Release();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }