AssetOperationHandle类新增便捷方法,便于链式编程

TextAsset asset;
                YooAssets.LoadAssetAsync<TextAsset>(name).WaitForAsyncOperationComplete().GetAssetObjet<TextAsset>(out asset).Release();
                YooAssets.LoadAssetAsync<TextAsset>(name).Completed += handler => {
                    handler.GetAssetObjet(out asset).Release();
                };
pull/17/head
Y-way 2022-06-28 19:17:47 +08:00
parent 727d841d47
commit 1e39b1af6d
1 changed files with 28 additions and 10 deletions

View File

@ -49,7 +49,27 @@ namespace YooAsset
return Provider.AssetObject;
}
}
/// <summary>
/// 获取资源对象
/// </summary>
/// <typeparam name="TAsset"></typeparam>
/// <param name="asset"></param>
/// <returns></returns>
public AssetOperationHandle GetAssetObjet<TAsset>(out TAsset asset) where TAsset : UnityEngine.Object
{
asset = AssetObject as TAsset;
return this;
}
/// <summary>
/// 等待异步执行完毕
/// </summary>
public AssetOperationHandle WaitForAsyncOperationComplete()
{
if (IsValid == false)
return this;
Provider.WaitForAsyncComplete();
return this;
}
/// <summary>
/// 等待异步执行完毕
/// </summary>
@ -109,8 +129,6 @@ namespace YooAsset
{
return InstantiateAsyncInternal(position, rotation, parent, true);
}
private GameObject InstantiateSyncInternal(Vector3 position, Quaternion rotation, Transform parent, bool setPositionRotation)
{
if (IsValid == false)