From 67677f6a57e23ca00fc485d50cd2a12eaed3e94b Mon Sep 17 00:00:00 2001 From: DCFApixels <99481254+DCFApixels@users.noreply.github.com> Date: Mon, 24 Mar 2025 10:00:02 +0800 Subject: [PATCH] fix disabled domain reload --- src/Internal/Editor/EcsGUI.Layout.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/Internal/Editor/EcsGUI.Layout.cs b/src/Internal/Editor/EcsGUI.Layout.cs index 799df86..eb70129 100644 --- a/src/Internal/Editor/EcsGUI.Layout.cs +++ b/src/Internal/Editor/EcsGUI.Layout.cs @@ -324,12 +324,16 @@ namespace DCFApixels.DragonECS.Unity.Editors } #region Default DrawRuntimeData - [InitializeOnLoadMethod] + [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)] private static void ResetRuntimeComponentReflectionCache() { + foreach (var item in _runtimeComponentReflectionCaches) + { + item.Value.Dispose(); + } _runtimeComponentReflectionCaches.Clear(); } - internal class RuntimeComponentReflectionCache + internal class RuntimeComponentReflectionCache : IDisposable { public readonly Type Type; @@ -364,6 +368,14 @@ namespace DCFApixels.DragonECS.Unity.Editors } } } + public void Dispose() + { + if(Wrapper != null) + { + UnityObject.DestroyImmediate(Wrapper); + } + } + public readonly struct FieldInfoData { public readonly FieldInfo FieldInfo; @@ -469,7 +481,6 @@ namespace DCFApixels.DragonECS.Unity.Editors else { EditorGUI.BeginChangeCheck(); - //WrapperBase wrapper = RefEditorWrapper.Take(data); RefEditorWrapper wrapper = cache.Wrapper;