private T NativeLoad <T>(string fileName) where T : class
        {
            var res = UnityResources.Load(fileName, typeof(T)) as T;

            if (res == null)
            {
                throw new Exception("Failed to load " + fileName + " as " + typeof(T));
            }
            return(res);
        }
Beispiel #2
0
 public static T Load(string path)
 {
     if (table.TryGetValue(path, out WeakReference <T> reference))
     {
         if (!reference.TryGetTarget(out T value))
         {
             value = UnityResources.Load <T>(path);
             reference.SetTarget(value);
         }
         return(value);
     }
     else
     {
         T value = UnityResources.Load <T>(path);
         table[path] = new WeakReference <T>(value);
         return(value);
     }
 }