async static public UniTask <T?> LoadAsync(string path) { if (cache.TryGetValue(path, out var asset)) { if (asset) { return(asset); } } var result = await ResourcesUtil.LoadAsync <T>(path); cache[path] = result; return(result); }
public async static UniTask <T?> LoadAsync(string path) { if (cache.TryGetValue(path, out var weakRef)) { if (weakRef.TryGetTarget(out var asset)) { if (asset) { return(asset); } } } var result = await ResourcesUtil.LoadAsync <T>(path); if (result) { cache[path] = new System.WeakReference <T>(result !); } return(result); }