释放资源前判断资源合法性

This commit is contained in:
ALEXTANG
2023-12-06 11:35:11 +08:00
parent f248757401
commit 818a74f437
2 changed files with 2 additions and 2 deletions

View File

@@ -31,7 +31,7 @@ namespace TEngine
/// </summary> /// </summary>
public void Clear() public void Clear()
{ {
if (_handle != null) if (_handle is { IsValid: true })
{ {
_handle.Dispose(); _handle.Dispose();
} }

View File

@@ -59,7 +59,7 @@ namespace TEngine
public void Bind(AssetOperationHandle operation, string assetLocation, AssetReference parent = null, public void Bind(AssetOperationHandle operation, string assetLocation, AssetReference parent = null,
string packageName = "") string packageName = "")
{ {
if (_operationHandle != null) if (_operationHandle is { IsValid: true })
{ {
Log.Warning($"rebind AssetReference gameObject.name:{gameObject.name} assetLocation:{assetLocation}"); Log.Warning($"rebind AssetReference gameObject.name:{gameObject.name} assetLocation:{assetLocation}");
_operationHandle.Dispose(); _operationHandle.Dispose();