123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- 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--;
- Asset.CacheCount[path] = count;
- }
- if (count > 0) return;
- Asset asset;
- if (Asset.Cache.TryGetValue(path, out asset))
- {
- asset.Release();
- }
- }
- else
- {
- }
- }
- }
- }
|