diff --git a/Assets/YooAsset/Runtime/AssetSystem/Handles/AssetOperationHandle.cs b/Assets/YooAsset/Runtime/AssetSystem/Handles/AssetOperationHandle.cs index 7c795ae..d59f27e 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Handles/AssetOperationHandle.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Handles/AssetOperationHandle.cs @@ -11,10 +11,7 @@ namespace YooAsset } internal override void InvokeCallback() { - if (IsValid) - { - _callback?.Invoke(this); - } + _callback?.Invoke(this); } /// diff --git a/Assets/YooAsset/Runtime/AssetSystem/Handles/SceneOperationHandle.cs b/Assets/YooAsset/Runtime/AssetSystem/Handles/SceneOperationHandle.cs index 0281f88..5d0ed59 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Handles/SceneOperationHandle.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Handles/SceneOperationHandle.cs @@ -11,10 +11,7 @@ namespace YooAsset } internal override void InvokeCallback() { - if (IsValid) - { - _callback?.Invoke(this); - } + _callback?.Invoke(this); } /// diff --git a/Assets/YooAsset/Runtime/AssetSystem/Handles/SubAssetsOperationHandle.cs b/Assets/YooAsset/Runtime/AssetSystem/Handles/SubAssetsOperationHandle.cs index 2d3486c..8d80f13 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Handles/SubAssetsOperationHandle.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Handles/SubAssetsOperationHandle.cs @@ -10,10 +10,7 @@ namespace YooAsset } internal override void InvokeCallback() { - if (IsValid) - { - _callback?.Invoke(this); - } + _callback?.Invoke(this); } /// diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/ProviderBase.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/ProviderBase.cs index 2688acd..fc34823 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Provider/ProviderBase.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/ProviderBase.cs @@ -224,9 +224,14 @@ namespace YooAsset } protected void InvokeCompletion() { - foreach (var handle in _handles) + // 注意:创建临时列表是为了防止外部逻辑在回调函数内创建或者释放资源句柄。 + List tempers = new List(_handles); + foreach (var hande in tempers) { - handle.InvokeCallback(); + if (hande.IsValid) + { + hande.InvokeCallback(); + } } _waitHandle?.Set(); }