mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-06-09 20:23:42 +00:00
fix #734
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
@@ -72,7 +73,10 @@ namespace YooAsset
|
|||||||
// 释放所有资源句柄
|
// 释放所有资源句柄
|
||||||
if (_options.ReleaseAllHandles)
|
if (_options.ReleaseAllHandles)
|
||||||
{
|
{
|
||||||
foreach (var provider in _resManager.ProviderDic.Values)
|
// 注意:创建快照,因为释放句柄可能触发自动卸载逻辑(AutoUnloadBundleWhenUnused),
|
||||||
|
// 进而修改 ProviderDic 容器,导致遍历时抛出 InvalidOperationException。
|
||||||
|
var snapshot = new List<ProviderOperation>(_resManager.ProviderDic.Values);
|
||||||
|
foreach (var provider in snapshot)
|
||||||
{
|
{
|
||||||
provider.ReleaseAllHandles();
|
provider.ReleaseAllHandles();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user