Skip to content

Commit 0fe8966

Browse files
committed
fix(UI): 修正卸载UI资源时实例销毁顺序问题
在卸载UI资源时,先销毁UI实例再进行资源卸载,避免资源引用未释放的问题。对于非Bundle资源,使用UnloadUnusedAssets确保资源完全释放。
1 parent ae8653f commit 0fe8966

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

Runtime/UGUIFormHelper.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,16 +182,15 @@ public override void ReleaseUIForm(object uiFormAsset, object uiFormInstance, ob
182182
return;
183183
}
184184

185+
Destroy((Object)uiFormInstance);
185186
if (uiFormAssetPath.IndexOf(Utility.Asset.Path.BundlesDirectoryName, StringComparison.OrdinalIgnoreCase) >= 0)
186187
{
187188
m_AssetComponent.UnloadAsset(uiFormAssetPath);
188189
}
189190
else
190191
{
191-
UnityEngine.Resources.UnloadAsset((Object)uiFormInstance);
192+
UnityEngine.Resources.UnloadUnusedAssets();
192193
}
193-
194-
Destroy((Object)uiFormInstance);
195194
}
196195

197196
[UnityEngine.Scripting.Preserve]

0 commit comments

Comments
 (0)