如果多次调用
// 异步加载资源 await FW.ResourceManager.LoadAssetAsync(assetPath, priority); await FW.ResourceManager.LoadGameObjectAsync(assetPath, priority);
加载同一个路径的资源 不是常驻的资源
最终会执行到
public async UniTask LoadAssetAsync(string assetPath,uint priority) where T : UnityEngine.Object
{
if (string.IsNullOrEmpty(assetPath))
{
Log.Error("[ResourceGroup] 资源路径为空");
return null;
}
// 调用 YooAsset 加载
AssetHandle handle = YooAssets.LoadAssetAsync<T>(assetPath,priority);
await handle.ToUniTask();
if (handle.Status != EOperationStatus.Succeed)
{
Log.Error("[ResourceGroup] 加载资源失败: {0}, 错误: {1}", assetPath, handle.LastError);
return null;
}
T asset = handle.AssetObject as T;
if (asset != null)
{
_assetToHandle[asset] = handle;
}
return asset;
}
AssetHandle handle = YooAssets.LoadAssetAsync(assetPath,priority);
这个方法如果多次调用同一个地址 返回的 handle 是不同的实例
但是里面的AssetObject 指向的是一个
执行之后第一次调用的时候的 handle 不就丢失引用了么
多次下来 _assetToHandle 只会保存最后一次的 handle ?
如果多次调用
// 异步加载资源 await FW.ResourceManager.LoadAssetAsync(assetPath, priority); await FW.ResourceManager.LoadGameObjectAsync(assetPath, priority);
加载同一个路径的资源 不是常驻的资源
最终会执行到
public async UniTask LoadAssetAsync(string assetPath,uint priority) where T : UnityEngine.Object
{
if (string.IsNullOrEmpty(assetPath))
{
Log.Error("[ResourceGroup] 资源路径为空");
return null;
}
AssetHandle handle = YooAssets.LoadAssetAsync(assetPath,priority);
这个方法如果多次调用同一个地址 返回的 handle 是不同的实例
但是里面的AssetObject 指向的是一个
执行之后第一次调用的时候的 handle 不就丢失引用了么
多次下来 _assetToHandle 只会保存最后一次的 handle ?