GFGAsset.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using UnityEngine;
  2. using YooAsset;
  3. namespace GFGGame
  4. {
  5. public class GFGAsset
  6. {
  7. public static T Load<T>(string path) where T : Object
  8. {
  9. //VEngine.Logger.I($"GFGAsset.Load {path} {Random.Range(0, int.MaxValue)}");
  10. T t = null;
  11. if (path.Contains("Asset"))
  12. {
  13. //Asset asset = VEngine.Asset.Load(path, typeof(T));
  14. //if (asset != null)
  15. //{
  16. // t = asset.asset as T;
  17. //}
  18. ResourcePackage package;
  19. if (path.Contains("Assets/Res/"))
  20. {
  21. package = YooAssets.GetPackage(VersionController.PackageName_GameArt);
  22. }
  23. else
  24. {
  25. package = YooAssets.GetPackage(VersionController.PackageName_GameLogic);
  26. }
  27. AssetOperationHandle handle = package.LoadAssetSync<T>(path);
  28. if(handle != null)
  29. {
  30. var t1 = typeof(T);
  31. var t2 = typeof(GameObject);
  32. if (t1 == t2)
  33. {
  34. var t3 = handle.InstantiateSync();
  35. t = t3 as T;
  36. }
  37. else
  38. {
  39. t = handle.AssetObject as T;
  40. }
  41. }
  42. }
  43. else
  44. {
  45. t = Resources.Load<T>(path);
  46. }
  47. return t;
  48. }
  49. public static void Release(string path)
  50. {
  51. //VEngine.Logger.I($"GFGAsset.Release {path} {Random.Range(0, int.MaxValue)}");
  52. if (path.Contains("Asset"))
  53. {
  54. //Asset asset;
  55. //if (Asset.Cache.TryGetValue(path, out asset))
  56. //{
  57. // asset.Release();
  58. //}
  59. }
  60. else
  61. {
  62. }
  63. }
  64. }
  65. }