示例#1
0
        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);
        }
示例#2
0
        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);
        }