diff --git a/Assets/YooAsset/Runtime/AssetSystem/Handles/AssetOperationHandle.cs b/Assets/YooAsset/Runtime/AssetSystem/Handles/AssetOperationHandle.cs index 2bbc916..f9f9451 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Handles/AssetOperationHandle.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Handles/AssetOperationHandle.cs @@ -1,9 +1,10 @@ -using UnityEngine; +using System; using System.Collections.Generic; +using UnityEngine; namespace YooAsset { - public sealed class AssetOperationHandle : OperationHandleBase + public sealed class AssetOperationHandle : OperationHandleBase, IDisposable { private System.Action _callback; @@ -37,6 +38,33 @@ namespace YooAsset } } + /// + /// 等待异步执行完毕 + /// + public void WaitForAsyncComplete() + { + if (IsValidWithWarning == false) + return; + Provider.WaitForAsyncComplete(); + } + + /// + /// 释放资源句柄 + /// + public void Release() + { + this.ReleaseInternal(); + } + + /// + /// 释放资源句柄 + /// + public void Dispose() + { + this.ReleaseInternal(); + } + + /// /// 资源对象 /// @@ -61,25 +89,6 @@ namespace YooAsset return Provider.AssetObject as TAsset; } - /// - /// 等待异步执行完毕 - /// - public void WaitForAsyncComplete() - { - if (IsValidWithWarning == false) - return; - Provider.WaitForAsyncComplete(); - } - - /// - /// 释放资源句柄 - /// - public void Release() - { - this.ReleaseInternal(); - } - - /// /// 同步初始化游戏对象 /// diff --git a/Assets/YooAsset/Runtime/AssetSystem/Handles/OperationHandleBase.cs b/Assets/YooAsset/Runtime/AssetSystem/Handles/OperationHandleBase.cs index b08a44c..6c8f081 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Handles/OperationHandleBase.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Handles/OperationHandleBase.cs @@ -3,20 +3,8 @@ using System.Collections; namespace YooAsset { - public abstract class OperationHandleBase : IEnumerator, IDisposable + public abstract class OperationHandleBase : IEnumerator { - private bool _isDisposed; - public void Dispose() - { - if (_isDisposed) - { - return; - } - - _isDisposed = true; - ReleaseInternal(); - } - private readonly AssetInfo _assetInfo; internal ProviderBase Provider { private set; get; } @@ -27,7 +15,6 @@ namespace YooAsset } internal abstract void InvokeCallback(); - /// /// 获取资源信息 /// diff --git a/Assets/YooAsset/Runtime/AssetSystem/Handles/RawFileOperationHandle.cs b/Assets/YooAsset/Runtime/AssetSystem/Handles/RawFileOperationHandle.cs index 08d244c..4f41857 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Handles/RawFileOperationHandle.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Handles/RawFileOperationHandle.cs @@ -1,9 +1,10 @@ -using System.IO; +using System; +using System.IO; using System.Text; namespace YooAsset { - public class RawFileOperationHandle : OperationHandleBase + public class RawFileOperationHandle : OperationHandleBase, IDisposable { private System.Action _callback; @@ -54,7 +55,15 @@ namespace YooAsset { this.ReleaseInternal(); } - + + /// + /// 释放资源句柄 + /// + public void Dispose() + { + this.ReleaseInternal(); + } + /// /// 获取原生文件的二进制数据 diff --git a/Assets/YooAsset/Runtime/AssetSystem/Handles/SubAssetsOperationHandle.cs b/Assets/YooAsset/Runtime/AssetSystem/Handles/SubAssetsOperationHandle.cs index 59ee557..9c050a4 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Handles/SubAssetsOperationHandle.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Handles/SubAssetsOperationHandle.cs @@ -1,8 +1,9 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; namespace YooAsset { - public sealed class SubAssetsOperationHandle : OperationHandleBase + public sealed class SubAssetsOperationHandle : OperationHandleBase, IDisposable { private System.Action _callback; @@ -36,19 +37,6 @@ namespace YooAsset } } - /// - /// 子资源对象集合 - /// - public UnityEngine.Object[] AllAssetObjects - { - get - { - if (IsValidWithWarning == false) - return null; - return Provider.AllAssetObjects; - } - } - /// /// 等待异步执行完毕 /// @@ -67,6 +55,27 @@ namespace YooAsset this.ReleaseInternal(); } + /// + /// 释放资源句柄 + /// + public void Dispose() + { + this.ReleaseInternal(); + } + + + /// + /// 子资源对象集合 + /// + public UnityEngine.Object[] AllAssetObjects + { + get + { + if (IsValidWithWarning == false) + return null; + return Provider.AllAssetObjects; + } + } /// /// 获取子资源对象