GFGAsset.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using VEngine;
  5. namespace GFGGame
  6. {
  7. public class GFGAsset
  8. {
  9. public static T Load<T>(string path) where T:Object
  10. {
  11. VEngine.Logger.I($"GFGAsset.Load {path} {Random.Range(0, int.MaxValue)}");
  12. T t = null;
  13. if (path.Contains("Asset"))
  14. {
  15. Asset asset = VEngine.Asset.Load(path, typeof(T));
  16. if (asset != null)
  17. {
  18. t = asset.asset as T;
  19. }
  20. }
  21. else
  22. {
  23. t = Resources.Load<T>(path);
  24. }
  25. return t;
  26. }
  27. public static void Release(string path)
  28. {
  29. VEngine.Logger.I($"GFGAsset.Release {path} {Random.Range(0, int.MaxValue)}");
  30. if (path.Contains("Asset"))
  31. {
  32. Asset asset;
  33. if (Asset.Cache.TryGetValue(path, out asset))
  34. {
  35. asset.Release();
  36. }
  37. }
  38. else
  39. {
  40. }
  41. }
  42. }
  43. }