From 1c7c2d2a0bc7ca82193e745a2d6f3bfb6ef7f58b Mon Sep 17 00:00:00 2001 From: Jurjen Biewenga Date: Tue, 14 Jan 2025 09:33:38 +0200 Subject: [PATCH] Fix ModelInspector tree view expansion resetting when domain reload is disabled The running number was never reset so the IDs never matched --- .../Unity/Editor/ModelInspectorValueProxies.cs | 2 ++ .../Client/Unity/Editor/ModelInspectorWindow.cs | 12 +++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/MetaplaySDK/Client/Unity/Editor/ModelInspectorValueProxies.cs b/MetaplaySDK/Client/Unity/Editor/ModelInspectorValueProxies.cs index 400466f78b..3caeb3c933 100644 --- a/MetaplaySDK/Client/Unity/Editor/ModelInspectorValueProxies.cs +++ b/MetaplaySDK/Client/Unity/Editor/ModelInspectorValueProxies.cs @@ -25,6 +25,8 @@ public abstract class ValueProxyBase // Generate unique ids for proxies static int _nextUniqueId; + internal static void ResetUniqueId() => _nextUniqueId = 0; + static int GenerateUniqueId() { return _nextUniqueId++; diff --git a/MetaplaySDK/Client/Unity/Editor/ModelInspectorWindow.cs b/MetaplaySDK/Client/Unity/Editor/ModelInspectorWindow.cs index 0013c31835..99a618c9cb 100644 --- a/MetaplaySDK/Client/Unity/Editor/ModelInspectorWindow.cs +++ b/MetaplaySDK/Client/Unity/Editor/ModelInspectorWindow.cs @@ -61,7 +61,7 @@ public class ModelInspectorWindow : EditorWindow // UI implementation specific fields (IMGUI) [NonSerialized] bool _treeViewInitialized; - [NonSerialized] TreeViewState _treeViewState; + [SerializeField] TreeViewState _treeViewState; [SerializeField] MultiColumnHeaderState _multiColumnHeaderState; SearchField _searchField; ModelInspectorTreeView _treeView; @@ -173,10 +173,12 @@ void OnPlayModeStateChanged(PlayModeStateChange state) { if (state == PlayModeStateChange.ExitingPlayMode) { - _model = null; - _initialized = false; - _modelInspectorArgs = new ModelInspectorArgs(); - _footerBoxStyle = null; + ValueProxyBase.ResetUniqueId(); + _treeViewState = _treeView?.state; + _model = null; + _initialized = false; + _modelInspectorArgs = new ModelInspectorArgs(); + _footerBoxStyle = null; } } -- 2.45.2.windows.1