From 513a250c64e51aaf9c217f2d2a170537ef01edce Mon Sep 17 00:00:00 2001 From: VladV Date: Wed, 22 Mar 2023 11:49:53 +0400 Subject: [PATCH] Add RunValidationIfRequired api --- Editor.Integrations/Odin/OdinFieldDrawer.cs | 6 +----- Editor.Integrations/Odin/OdinObjectDrawer.cs | 6 +----- Editor.Samples/TriSamplesWindow.cs | 6 +----- Editor/TriEditor.cs | 6 +----- Editor/TriPropertyTree.cs | 10 ++++++++++ 5 files changed, 14 insertions(+), 20 deletions(-) diff --git a/Editor.Integrations/Odin/OdinFieldDrawer.cs b/Editor.Integrations/Odin/OdinFieldDrawer.cs index c1b5bdc..09e925d 100644 --- a/Editor.Integrations/Odin/OdinFieldDrawer.cs +++ b/Editor.Integrations/Odin/OdinFieldDrawer.cs @@ -66,11 +66,7 @@ protected override void DrawPropertyLayout(GUIContent label) } _propertyTree.Update(); - - if (_propertyTree.ValidationRequired) - { - _propertyTree.RunValidation(); - } + _propertyTree.RunValidationIfRequired(); _labelOverrideContext.Label = label ?? GUIContent.none; diff --git a/Editor.Integrations/Odin/OdinObjectDrawer.cs b/Editor.Integrations/Odin/OdinObjectDrawer.cs index 22b9df7..9c6a207 100644 --- a/Editor.Integrations/Odin/OdinObjectDrawer.cs +++ b/Editor.Integrations/Odin/OdinObjectDrawer.cs @@ -65,11 +65,7 @@ protected override void DrawPropertyLayout(GUIContent label) } _propertyTree.Update(); - - if (_propertyTree.ValidationRequired) - { - _propertyTree.RunValidation(); - } + _propertyTree.RunValidationIfRequired(); using (TriGuiHelper.PushEditorTarget(ValueEntry.SmartValue)) { diff --git a/Editor.Samples/TriSamplesWindow.cs b/Editor.Samples/TriSamplesWindow.cs index 8afff63..f8df986 100644 --- a/Editor.Samples/TriSamplesWindow.cs +++ b/Editor.Samples/TriSamplesWindow.cs @@ -94,11 +94,7 @@ private void DrawElement() _currentSerializedObject.UpdateIfRequiredOrScript(); _currentPropertyTree.Update(); - - if (_currentPropertyTree.ValidationRequired) - { - _currentPropertyTree.RunValidation(); - } + _currentPropertyTree.RunValidationIfRequired(); GUILayout.Space(10); GUILayout.Label("Preview", EditorStyles.boldLabel); diff --git a/Editor/TriEditor.cs b/Editor/TriEditor.cs index fb615f7..4420144 100644 --- a/Editor/TriEditor.cs +++ b/Editor/TriEditor.cs @@ -53,11 +53,7 @@ public override void OnInspectorGUI() serializedObject.UpdateIfRequiredOrScript(); _inspector.Update(); - - if (_inspector.ValidationRequired) - { - _inspector.RunValidation(); - } + _inspector.RunValidationIfRequired(); using (TriGuiHelper.PushEditorTarget(target)) { diff --git a/Editor/TriPropertyTree.cs b/Editor/TriPropertyTree.cs index 76d18e9..1fc0d83 100644 --- a/Editor/TriPropertyTree.cs +++ b/Editor/TriPropertyTree.cs @@ -40,6 +40,16 @@ public virtual bool ApplyChanges() return false; } + public void RunValidationIfRequired() + { + if (!ValidationRequired) + { + return; + } + + RunValidation(); + } + public void RunValidation() { ValidationRequired = false;