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,45 +49,32 @@ namespace YooAsset
return Provider.AssetObject; return Provider.AssetObject;
} }
} }
/// <summary>
/// 获取资源对象 /// <summary>
/// </summary> /// 获取资源对象
/// <typeparam name="TAsset"></typeparam> /// </summary>
/// <param name="asset"></param> /// <typeparam name="TAsset">资源类型</typeparam>
/// <returns></returns> public TAsset GetAssetObjet<TAsset>() where TAsset : UnityEngine.Object
public AssetOperationHandle GetAssetObjet<TAsset>(out TAsset asset) where TAsset : UnityEngine.Object {
{ if (IsValid == false)
if(Status != EOperationStatus.Succeed) return null;
{ return Provider.AssetObject as TAsset;
YooLogger.Warning($"The {Provider.MainAssetInfo.AssetPath}[{Provider.MainAssetInfo.AssetType}] is not success.Error[{Provider.LastError}]"); }
}
asset = AssetObject as TAsset;
return this;
}
/// <summary> /// <summary>
/// 等待异步执行完毕 /// 等待异步执行完毕
/// </summary> /// </summary>
public AssetOperationHandle WaitForAsyncOperationComplete() public void WaitForAsyncComplete()
{ {
if (IsValid == false) if (IsValid == false)
return this; return;
Provider.WaitForAsyncComplete(); Provider.WaitForAsyncComplete();
return this;
} }
/// <summary>
/// 等待异步执行完毕
/// </summary>
public void WaitForAsyncComplete()
{
if(IsValid == false)
return;
Provider.WaitForAsyncComplete();
}
/// <summary> /// <summary>
/// 释放资源句柄 /// 释放资源句柄
/// </summary> /// </summary>
public void Release() public void Release()
{ {
this.ReleaseInternal(); this.ReleaseInternal();
} }
@ -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)