1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using VEngine;
- 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;
- }
- }
- 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"))
- {
- int count = 0;
- if (Asset.CacheCount.TryGetValue(path, out count))
- {
- count--;
- }
- if (count > 0) return;
- Asset asset;
- if (Asset.Cache.TryGetValue(path, out asset))
- {
- asset.Release();
- }
- }
- else
- {
- }
- }
- }
- }
|