Example #1
0
 private T GetResWithCache <T>(string bundle, string name, ObjectRegister <T> cache, bool logError = true) where T : UnityEngine.Object
 {
     if (name.IsInvStr())
     {
         return(null);
     }
     if (cache.ContainsKey(name))
     {
         return(cache[name]);
     }
     else
     {
         DLCAssetMgr.IsNextLogError = logError;
         T retGO = SelfBaseGlobal.DLCMgr.LoadAsset <T>(bundle, name);
         if (retGO == null)
         {
             if (logError)
             {
                 CLog.Error("no this res in bundle {0}, name = {1}", bundle, name);
             }
         }
         else
         {
             cache.Add(retGO);
         }
         return(retGO);
     }
 }
Example #2
0
 private T GetResWithCache(string bundle, string name, ObjectRegister <T> cache, bool logError = true)
 {
     if (name.IsInv())
     {
         return(null);
     }
     if (cache.ContainsKey(name))
     {
         return(cache[name]);
     }
     else
     {
         DLCManager.IsNextLogError = logError;
         var asset = DLCManager.LoadAsset <T>(bundle, name);
         if (asset == null)
         {
             return(null);
         }
         T retGO = asset.Object as T;
         if (retGO == null)
         {
             if (logError)
             {
                 CLog.Error("no this res in bundle {0}, name = {1}", bundle, name);
             }
         }
         else
         {
             if (!cache.ContainsKey(retGO.name))
             {
                 cache.Add(retGO);
             }
             else
             {
                 cache[retGO.name] = retGO;
             }
         }
         return(retGO);
     }
 }