From 5207b1a1c4fd35d8058caae8ad7b425f0321e0a1 Mon Sep 17 00:00:00 2001 From: sinaioutlander <49360850+sinaioutlander@users.noreply.github.com> Date: Mon, 16 Nov 2020 22:44:47 +1100 Subject: [PATCH] fix destroy logic with lists/dicts --- .../Reflection/CacheObject/CacheObjectBase.cs | 3 ++- .../InteractiveValue/InteractiveDictionary.cs | 15 +++++---------- .../InteractiveValue/InteractiveEnumerable.cs | 15 +++++---------- 3 files changed, 12 insertions(+), 21 deletions(-) diff --git a/src/Inspectors/Reflection/CacheObject/CacheObjectBase.cs b/src/Inspectors/Reflection/CacheObject/CacheObjectBase.cs index 69de94e..cf644a0 100644 --- a/src/Inspectors/Reflection/CacheObject/CacheObjectBase.cs +++ b/src/Inspectors/Reflection/CacheObject/CacheObjectBase.cs @@ -43,7 +43,8 @@ namespace UnityExplorer.Inspectors.Reflection public void Destroy() { - GameObject.Destroy(this.m_mainContent); + if (this.m_mainContent) + GameObject.Destroy(this.m_mainContent); } public virtual void UpdateValue() diff --git a/src/Inspectors/Reflection/InteractiveValue/InteractiveDictionary.cs b/src/Inspectors/Reflection/InteractiveValue/InteractiveDictionary.cs index 3cf9f00..6e6aa93 100644 --- a/src/Inspectors/Reflection/InteractiveValue/InteractiveDictionary.cs +++ b/src/Inspectors/Reflection/InteractiveValue/InteractiveDictionary.cs @@ -65,18 +65,13 @@ namespace UnityExplorer.Inspectors.Reflection { RefIDictionary = Value as IDictionary; - if (Value != null) + if (m_subContentParent.activeSelf) { - if (m_subContentParent.activeSelf) - { - GetCacheEntries(); - RefreshDisplay(); - } - else - m_recacheWanted = true; + GetCacheEntries(); + RefreshDisplay(); } else - m_entries.Clear(); + m_recacheWanted = true; base.OnValueUpdated(); } @@ -122,7 +117,7 @@ namespace UnityExplorer.Inspectors.Reflection } #if CPP - if (RefIDictionary == null && !Value.IsNullOrDestroyed()) + if (RefIDictionary == null && Value != null) RefIDictionary = EnumerateWithReflection(); #endif diff --git a/src/Inspectors/Reflection/InteractiveValue/InteractiveEnumerable.cs b/src/Inspectors/Reflection/InteractiveValue/InteractiveEnumerable.cs index 6f86064..83af2c4 100644 --- a/src/Inspectors/Reflection/InteractiveValue/InteractiveEnumerable.cs +++ b/src/Inspectors/Reflection/InteractiveValue/InteractiveEnumerable.cs @@ -49,18 +49,13 @@ namespace UnityExplorer.Inspectors.Reflection RefIEnumerable = Value as IEnumerable; RefIList = Value as IList; - if (Value != null) + if (m_subContentParent.activeSelf) { - if (m_subContentParent.activeSelf) - { - GetCacheEntries(); - RefreshDisplay(); - } - else - m_recacheWanted = true; + GetCacheEntries(); + RefreshDisplay(); } else - m_entries.Clear(); + m_recacheWanted = true; base.OnValueUpdated(); } @@ -108,7 +103,7 @@ namespace UnityExplorer.Inspectors.Reflection } #if CPP - if (RefIEnumerable == null && !Value.IsNullOrDestroyed()) + if (RefIEnumerable == null && Value != null) RefIEnumerable = EnumerateWithReflection(); #endif