Update AssetOperationHandle.cs

pull/18/head
hevinci 2022-06-30 12:12:44 +08:00
parent bb3065d08d
commit 5425e17d6f
1 changed files with 20 additions and 31 deletions

View File

@ -49,31 +49,18 @@ namespace YooAsset
return Provider.AssetObject; return Provider.AssetObject;
} }
} }
/// <summary> /// <summary>
/// 获取资源对象 /// 获取资源对象
/// </summary> /// </summary>
/// <typeparam name="TAsset"></typeparam> /// <typeparam name="TAsset">资源类型</typeparam>
/// <param name="asset"></param> public TAsset GetAssetObjet<TAsset>() where TAsset : UnityEngine.Object
/// <returns></returns>
public AssetOperationHandle GetAssetObjet<TAsset>(out TAsset asset) where TAsset : UnityEngine.Object
{
if(Status != EOperationStatus.Succeed)
{
YooLogger.Warning($"The {Provider.MainAssetInfo.AssetPath}[{Provider.MainAssetInfo.AssetType}] is not success.Error[{Provider.LastError}]");
}
asset = AssetObject as TAsset;
return this;
}
/// <summary>
/// 等待异步执行完毕
/// </summary>
public AssetOperationHandle WaitForAsyncOperationComplete()
{ {
if (IsValid == false) if (IsValid == false)
return this; return null;
Provider.WaitForAsyncComplete(); return Provider.AssetObject as TAsset;
return this;
} }
/// <summary> /// <summary>
/// 等待异步执行完毕 /// 等待异步执行完毕
/// </summary> /// </summary>
@ -133,6 +120,8 @@ namespace YooAsset
{ {
return InstantiateAsyncInternal(position, rotation, parent, true); return InstantiateAsyncInternal(position, rotation, parent, true);
} }
private GameObject InstantiateSyncInternal(Vector3 position, Quaternion rotation, Transform parent, bool setPositionRotation) private GameObject InstantiateSyncInternal(Vector3 position, Quaternion rotation, Transform parent, bool setPositionRotation)
{ {
if (IsValid == false) if (IsValid == false)