1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- using UnityEngine;
- using YooAsset;
- namespace GFGGame
- {
- public class GFGAsset
- {
- public static T Load<T>(string path) where T : Object
- {
- //VEngine.Logger.I($"GFGAsset.Load {path} {Random.Range(0, int.MaxValue)}");
- T t = null;
- if (path.Contains("Asset"))
- {
- //Asset asset = VEngine.Asset.Load(path, typeof(T));
- //if (asset != null)
- //{
- // t = asset.asset as T;
- //}
- ResourcePackage package;
- //if (path.Contains("Assets/Res/") && !path.Contains("Assets/Res/Animation"))
- //{
- // package = YooAssets.GetPackage(VersionController.PackageName_GameArt);
- //}
- //else
- //{
- package = YooAssets.GetPackage(VersionController.PackageName_GameLogic);
- //}
- AssetOperationHandle handle = package.LoadAssetSync<T>(path);
- if(handle != null)
- {
- var t1 = typeof(T);
- var t2 = typeof(GameObject);
- if (t1 == t2)
- {
- var t3 = handle.InstantiateSync();
- t = t3 as T;
- }
- else
- {
- t = handle.AssetObject as T;
- }
- }
- }
- else
- {
- t = Resources.Load<T>(path);
- }
- return t;
- }
- public static void Release(string path)
- {
- //VEngine.Logger.I($"GFGAsset.Release {path} {Random.Range(0, int.MaxValue)}");
- if (path.Contains("Asset"))
- {
- //Asset asset;
- //if (Asset.Cache.TryGetValue(path, out asset))
- //{
- // asset.Release();
- //}
- }
- else
- {
- }
- }
- }
- }
|