diff --git a/Assets/YooAsset/Runtime/ResourceManager/Handle/AllAssetsHandle.cs b/Assets/YooAsset/Runtime/ResourceManager/Handle/AllAssetsHandle.cs index ac620e63..0e611e56 100644 --- a/Assets/YooAsset/Runtime/ResourceManager/Handle/AllAssetsHandle.cs +++ b/Assets/YooAsset/Runtime/ResourceManager/Handle/AllAssetsHandle.cs @@ -1,9 +1,8 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; namespace YooAsset { - public sealed class AllAssetsHandle : HandleBase, IDisposable + public sealed class AllAssetsHandle : HandleBase { private System.Action _callback; @@ -47,23 +46,6 @@ namespace YooAsset Provider.WaitForAsyncComplete(); } - /// - /// 释放资源句柄 - /// - public void Release() - { - this.ReleaseInternal(); - } - - /// - /// 释放资源句柄 - /// - public void Dispose() - { - this.ReleaseInternal(); - } - - /// /// 子资源对象集合 /// diff --git a/Assets/YooAsset/Runtime/ResourceManager/Handle/AssetHandle.cs b/Assets/YooAsset/Runtime/ResourceManager/Handle/AssetHandle.cs index 33707131..3cc1a898 100644 --- a/Assets/YooAsset/Runtime/ResourceManager/Handle/AssetHandle.cs +++ b/Assets/YooAsset/Runtime/ResourceManager/Handle/AssetHandle.cs @@ -1,10 +1,8 @@ -using System; -using System.Collections.Generic; -using UnityEngine; +using UnityEngine; namespace YooAsset { - public sealed class AssetHandle : HandleBase, IDisposable + public sealed class AssetHandle : HandleBase { private System.Action _callback; @@ -48,22 +46,6 @@ namespace YooAsset Provider.WaitForAsyncComplete(); } - /// - /// 释放资源句柄 - /// - public void Release() - { - this.ReleaseInternal(); - } - - /// - /// 释放资源句柄 - /// - public void Dispose() - { - this.ReleaseInternal(); - } - /// /// 资源对象 diff --git a/Assets/YooAsset/Runtime/ResourceManager/Handle/HandleBase.cs b/Assets/YooAsset/Runtime/ResourceManager/Handle/HandleBase.cs index c856d59a..5c3fb267 100644 --- a/Assets/YooAsset/Runtime/ResourceManager/Handle/HandleBase.cs +++ b/Assets/YooAsset/Runtime/ResourceManager/Handle/HandleBase.cs @@ -3,7 +3,7 @@ using System.Collections; namespace YooAsset { - public abstract class HandleBase : IEnumerator + public abstract class HandleBase : IEnumerator, IDisposable { private readonly AssetInfo _assetInfo; internal ProviderOperation Provider { private set; get; } @@ -15,6 +15,25 @@ namespace YooAsset } internal abstract void InvokeCallback(); + /// + /// 释放资源句柄 + /// + public void Release() + { + if (IsValidWithWarning == false) + return; + Provider.ReleaseHandle(this); + Provider = null; + } + + /// + /// 释放资源句柄 + /// + public void Dispose() + { + this.Release(); + } + /// /// 获取资源信息 /// @@ -121,17 +140,6 @@ namespace YooAsset } } - /// - /// 释放句柄 - /// - internal void ReleaseInternal() - { - if (IsValidWithWarning == false) - return; - Provider.ReleaseHandle(this); - Provider = null; - } - #region 异步操作相关 /// /// 异步操作任务 diff --git a/Assets/YooAsset/Runtime/ResourceManager/Handle/RawFileHandle.cs b/Assets/YooAsset/Runtime/ResourceManager/Handle/RawFileHandle.cs index 6f04ba2c..d40d0c31 100644 --- a/Assets/YooAsset/Runtime/ResourceManager/Handle/RawFileHandle.cs +++ b/Assets/YooAsset/Runtime/ResourceManager/Handle/RawFileHandle.cs @@ -1,10 +1,7 @@ -using System; -using System.IO; -using System.Text; - + namespace YooAsset { - public class RawFileHandle : HandleBase, IDisposable + public class RawFileHandle : HandleBase { private System.Action _callback; @@ -48,22 +45,6 @@ namespace YooAsset Provider.WaitForAsyncComplete(); } - /// - /// 释放资源句柄 - /// - public void Release() - { - this.ReleaseInternal(); - } - - /// - /// 释放资源句柄 - /// - public void Dispose() - { - this.ReleaseInternal(); - } - /// /// 获取原生文件的二进制数据 diff --git a/Assets/YooAsset/Runtime/ResourceManager/Handle/SubAssetsHandle.cs b/Assets/YooAsset/Runtime/ResourceManager/Handle/SubAssetsHandle.cs index 8fc4cb43..6a2b85a3 100644 --- a/Assets/YooAsset/Runtime/ResourceManager/Handle/SubAssetsHandle.cs +++ b/Assets/YooAsset/Runtime/ResourceManager/Handle/SubAssetsHandle.cs @@ -1,9 +1,8 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; namespace YooAsset { - public sealed class SubAssetsHandle : HandleBase, IDisposable + public sealed class SubAssetsHandle : HandleBase { private System.Action _callback; @@ -47,22 +46,6 @@ namespace YooAsset Provider.WaitForAsyncComplete(); } - /// - /// 释放资源句柄 - /// - public void Release() - { - this.ReleaseInternal(); - } - - /// - /// 释放资源句柄 - /// - public void Dispose() - { - this.ReleaseInternal(); - } - /// /// 子资源对象集合 diff --git a/Assets/YooAsset/Runtime/ResourceManager/Provider/ProviderOperation.cs b/Assets/YooAsset/Runtime/ResourceManager/Provider/ProviderOperation.cs index 260ad8a7..cee8c42a 100644 --- a/Assets/YooAsset/Runtime/ResourceManager/Provider/ProviderOperation.cs +++ b/Assets/YooAsset/Runtime/ResourceManager/Provider/ProviderOperation.cs @@ -239,7 +239,7 @@ namespace YooAsset for (int i = _handles.Count - 1; i >= 0; i--) { var handle = _handles[i]; - handle.ReleaseInternal(); + handle.Release(); } } diff --git a/Assets/YooAsset/Runtime/ResourceManager/ResourceManager.cs b/Assets/YooAsset/Runtime/ResourceManager/ResourceManager.cs index b8ac7640..2c942df3 100644 --- a/Assets/YooAsset/Runtime/ResourceManager/ResourceManager.cs +++ b/Assets/YooAsset/Runtime/ResourceManager/ResourceManager.cs @@ -290,7 +290,7 @@ namespace YooAsset { if (sceneHandle.SceneObject == scene) { - sceneHandle.ReleaseInternal(); + sceneHandle.Release(); removeList.Add(sceneHandle); } }