From a95cdde29f86ac2ff806a4ceeb801168f3406e0b Mon Sep 17 00:00:00 2001 From: poi-vrc <77053052+poi-vrc@users.noreply.github.com> Date: Wed, 1 Jan 2025 16:30:30 +0800 Subject: [PATCH] refactor(ui): make UI element-aware, respond to attach detach --- .github/workflows/unity-tests.yml | 1 - .../Cabinet/OneConfCabinetProvider.cs | 4 +- .../Configurator/Views/OneConfCabinetView.cs | 9 +- Editor/Inspector/EditorBase.cs | 3 - .../Inspector/Views/AnimatorParametersView.cs | 28 +--- Editor/Inspector/Views/GroupDynamicsView.cs | 34 ++--- Editor/Inspector/Views/MenuGroupView.cs | 30 +--- Editor/Inspector/Views/MenuInstallView.cs | 16 +- Editor/Inspector/Views/MenuItemView.cs | 74 ++++----- Editor/Inspector/Views/ParameterSlotView.cs | 40 ++--- .../SmartControlPropertyGroupComponentView.cs | 36 ++--- .../Views/SmartControlPropertyGroupView.cs | 56 +++---- Editor/Inspector/Views/SmartControlView.cs | 141 +++++++----------- Editor/UI/DTLegacyEditorWindow.cs | 17 +-- Editor/UI/DTMainEditorWindow.cs | 9 +- Editor/UI/MappingEditorWindow.cs | 2 - .../OneConfWearableConfigPresenter.cs | 8 - Editor/UI/Views/AvatarSubView.cs | 25 ++-- Editor/UI/Views/ElementView.cs | 63 ++++---- Editor/UI/Views/IEditorView.cs | 10 -- .../Views/{IMGUIViewBase.cs => IMGUIView.cs} | 91 +++++------ ...MGUIViewBase.cs.meta => IMGUIView.cs.meta} | 0 Editor/UI/Views/LegacyView.cs | 2 +- Editor/UI/Views/MainView.cs | 38 ++--- Editor/UI/Views/MappingEditorView.cs | 2 +- .../Modules/WearableModuleEditorIMGUI.cs | 2 +- Editor/UI/Views/OneConfDressSubView.cs | 25 +--- Editor/UI/Views/OneConfWearableConfigView.cs | 124 +++++++-------- Editor/UI/Views/ToolSettingsSubView.cs | 27 +--- 29 files changed, 328 insertions(+), 589 deletions(-) rename Editor/UI/Views/{IMGUIViewBase.cs => IMGUIView.cs} (70%) rename Editor/UI/Views/{IMGUIViewBase.cs.meta => IMGUIView.cs.meta} (100%) diff --git a/.github/workflows/unity-tests.yml b/.github/workflows/unity-tests.yml index ad0829b1..2378ca97 100644 --- a/.github/workflows/unity-tests.yml +++ b/.github/workflows/unity-tests.yml @@ -4,7 +4,6 @@ on: push: branches: - master - - upgrade-u22-cs8 paths: - "**/*.cs" - ".github/unity-project/**/*" diff --git a/Editor/Configurator/Cabinet/OneConfCabinetProvider.cs b/Editor/Configurator/Cabinet/OneConfCabinetProvider.cs index b2ab98a0..62ae0195 100644 --- a/Editor/Configurator/Cabinet/OneConfCabinetProvider.cs +++ b/Editor/Configurator/Cabinet/OneConfCabinetProvider.cs @@ -35,9 +35,7 @@ public OneConfCabinetProvider(GameObject avatarGameObject) public VisualElement CreateView() { - var view = new OneConfCabinetView(_avatarGameObject); - view.OnEnable(); - return view; + return new OneConfCabinetView(_avatarGameObject); } public List GetOutfits() diff --git a/Editor/Configurator/Views/OneConfCabinetView.cs b/Editor/Configurator/Views/OneConfCabinetView.cs index 51e33128..386c6e39 100644 --- a/Editor/Configurator/Views/OneConfCabinetView.cs +++ b/Editor/Configurator/Views/OneConfCabinetView.cs @@ -60,6 +60,8 @@ internal class OneConfCabinetView : ElementView, IOneConfCabinetView public OneConfCabinetView(GameObject avatarGameObject) { _presenter = new OneConfCabinetPresenter(this, avatarGameObject); + InitVisualTree(); + t.LocalizeElement(this); } private void InitVisualTree() @@ -98,13 +100,6 @@ private void InitVisualTree() Add(_savedToggle); } - public override void OnEnable() - { - InitVisualTree(); - t.LocalizeElement(this); - RaiseLoadEvent(); - } - public override void Repaint() { _armatureNameField.value = ArmatureName; diff --git a/Editor/Inspector/EditorBase.cs b/Editor/Inspector/EditorBase.cs index 9ac20460..36db99a5 100644 --- a/Editor/Inspector/EditorBase.cs +++ b/Editor/Inspector/EditorBase.cs @@ -91,7 +91,6 @@ private void CleanUp() { if (_view != null) { - _view.OnDisable(); if (_viewContainer != null && _viewContainer.Contains(_view)) { _viewContainer.Remove(_view); @@ -123,7 +122,6 @@ private void CreateNewView() _view = CreateView(); _viewContainer.Add(_view); - _view.OnEnable(); _view.Bind(new SerializedObject(target)); } @@ -132,7 +130,6 @@ private void CreateNewView() public void OnDisable() { _view?.Unbind(); - _view?.OnDisable(); _view = null; } } diff --git a/Editor/Inspector/Views/AnimatorParametersView.cs b/Editor/Inspector/Views/AnimatorParametersView.cs index 1272f88c..3681a997 100644 --- a/Editor/Inspector/Views/AnimatorParametersView.cs +++ b/Editor/Inspector/Views/AnimatorParametersView.cs @@ -52,6 +52,11 @@ public AnimatorParametersView() Configs = new List(); _presenter = new AnimatorParametersPresenter(this); _animParamTextFields = new List(); + + InitVisualTree(); + RegisterCallback(evt => MouseEnter?.Invoke()); + RegisterCallback(evt => MouseLeave?.Invoke()); + t.LocalizeElement(this); } private void InitVisualTree() @@ -64,30 +69,13 @@ private void InitVisualTree() styleSheets.Add(styleSheet); } - _helpBoxContainer = Q("helpbox-container").First(); + _helpBoxContainer = Q("helpbox-container"); _helpBoxContainer.Add(CreateHelpBox(t._("inspector.animParams.helpbox.description"), MessageType.Info)); - _configsContainer = Q("configs-container").First(); - var addConfigBtn = Q