From 5425e17d6f4343bffce910e8fa2c13bf893837ac Mon Sep 17 00:00:00 2001 From: hevinci Date: Thu, 30 Jun 2022 12:12:44 +0800 Subject: [PATCH] Update AssetOperationHandle.cs --- .../Handles/AssetOperationHandle.cs | 51 ++++++++----------- 1 file changed, 20 insertions(+), 31 deletions(-) diff --git a/Assets/YooAsset/Runtime/AssetSystem/Handles/AssetOperationHandle.cs b/Assets/YooAsset/Runtime/AssetSystem/Handles/AssetOperationHandle.cs index add1558c..c1165679 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Handles/AssetOperationHandle.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Handles/AssetOperationHandle.cs @@ -49,45 +49,32 @@ namespace YooAsset return Provider.AssetObject; } } - /// - /// 获取资源对象 - /// - /// - /// - /// - public AssetOperationHandle GetAssetObjet(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; - } + + /// + /// 获取资源对象 + /// + /// 资源类型 + public TAsset GetAssetObjet() where TAsset : UnityEngine.Object + { + if (IsValid == false) + return null; + return Provider.AssetObject as TAsset; + } + /// /// 等待异步执行完毕 /// - public AssetOperationHandle WaitForAsyncOperationComplete() + public void WaitForAsyncComplete() { if (IsValid == false) - return this; + return; Provider.WaitForAsyncComplete(); - return this; } - /// - /// 等待异步执行完毕 - /// - public void WaitForAsyncComplete() - { - if(IsValid == false) - return; - Provider.WaitForAsyncComplete(); - } - /// - /// 释放资源句柄 - /// - public void Release() + /// + /// 释放资源句柄 + /// + public void Release() { this.ReleaseInternal(); } @@ -133,6 +120,8 @@ namespace YooAsset { return InstantiateAsyncInternal(position, rotation, parent, true); } + + private GameObject InstantiateSyncInternal(Vector3 position, Quaternion rotation, Transform parent, bool setPositionRotation) { if (IsValid == false)