From 0434d4235d416cb937218821f7c782a5ae1d7809 Mon Sep 17 00:00:00 2001 From: uurha Date: Sun, 1 Sep 2024 19:29:59 +0000 Subject: [PATCH] Merge pull request #51 from techno-dwarf-works/feature/refactoring Version 0.0.48 --- Editor/CustomEditors/MultiEditor.cs | 36 +++++++++++++++++------------ package.json | 2 +- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/Editor/CustomEditors/MultiEditor.cs b/Editor/CustomEditors/MultiEditor.cs index 5138238..bf18a88 100644 --- a/Editor/CustomEditors/MultiEditor.cs +++ b/Editor/CustomEditors/MultiEditor.cs @@ -99,35 +99,41 @@ protected void SetOverrideDefault(bool value) public override VisualElement CreateInspectorGUI() { - var m = Editor.CreateInstance(); - m.SetOverrideDefault(false); var container = new VisualElement(); - for (var i = 0; i < _preEditors.Count; i++) - { - var element = _preEditors[i].CreateInspectorGUI(); - if (element != null) - { - container.Add(element); - } - } + IteratePreEditors(container); if (!_overrideDefault) { InspectorElement.FillDefaultInspector(container, serializedObject, this); } - for (var i = 0; i < _postEditors.Count; i++) + IteratePostEditors(container); + + container.TrackSerializedObjectValue(serializedObject, OnSerializedObjectTrack); + return container; + } + + protected void IteratePreEditors(VisualElement container) + { + IterateEditors(_preEditors, container); + } + + protected void IteratePostEditors(VisualElement container) + { + IterateEditors(_postEditors, container); + } + + private void IterateEditors(List extendedEditors, VisualElement container) + { + for (var i = 0; i < extendedEditors.Count; i++) { - var element = _postEditors[i].CreateInspectorGUI(); + var element = extendedEditors[i].CreateInspectorGUI(); if (element != null) { container.Add(element); } } - - container.TrackSerializedObjectValue(serializedObject, OnSerializedObjectTrack); - return container; } protected virtual void OnSerializedObjectTrack(SerializedObject serializedObject) diff --git a/package.json b/package.json index 1324a03..98baf75 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "com.tdw.better.commons", "displayName": "Better Commons", - "version": "0.0.47", + "version": "0.0.48", "unity": "2021.3", "description": " ", "dependencies": {