释放资源判断资源是否有效

释放资源判断资源是否有效
This commit is contained in:
ALEXTANG
2023-10-26 14:07:38 +08:00
parent 6992d12c6c
commit cfaf82a623

View File

@@ -101,7 +101,6 @@ namespace TEngine
internal override void Shutdown() internal override void Shutdown()
{ {
ReleaseAllHandle();
#if !UNITY_WEBGL #if !UNITY_WEBGL
YooAssets.Destroy(); YooAssets.Destroy();
#endif #endif
@@ -114,13 +113,12 @@ namespace TEngine
while (iter.MoveNext()) while (iter.MoveNext())
{ {
AssetOperationHandle handle = iter.Current; AssetOperationHandle handle = iter.Current;
if (handle != null) if (handle is { IsValid: true })
{ {
handle.Dispose(); handle.Dispose();
handle = null; handle = null;
} }
} }
iter.Dispose(); iter.Dispose();
_releaseMaps.Clear(); _releaseMaps.Clear();
@@ -128,15 +126,15 @@ namespace TEngine
while (iter.MoveNext()) while (iter.MoveNext())
{ {
AssetOperationHandle handle = iter.Current; AssetOperationHandle handle = iter.Current;
if (handle != null) if (handle is { IsValid: true })
{ {
handle.Dispose(); handle.Dispose();
handle = null; handle = null;
} }
} }
iter.Dispose(); iter.Dispose();
_operationHandlesMaps.Clear(); _operationHandlesMaps.Clear();
_arcCacheTable = new ArcCacheTable<string, AssetOperationHandle>(ARCTableCapacity, OnAddAsset, OnRemoveAsset); _arcCacheTable = new ArcCacheTable<string, AssetOperationHandle>(ARCTableCapacity, OnAddAsset, OnRemoveAsset);
} }