Skip to content

Commit

Permalink
Add RunValidationIfRequired api
Browse files Browse the repository at this point in the history
  • Loading branch information
vanifatovvlad committed Mar 22, 2023
1 parent db3d602 commit 513a250
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 20 deletions.
6 changes: 1 addition & 5 deletions Editor.Integrations/Odin/OdinFieldDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,7 @@ protected override void DrawPropertyLayout(GUIContent label)
}

_propertyTree.Update();

if (_propertyTree.ValidationRequired)
{
_propertyTree.RunValidation();
}
_propertyTree.RunValidationIfRequired();

_labelOverrideContext.Label = label ?? GUIContent.none;

Expand Down
6 changes: 1 addition & 5 deletions Editor.Integrations/Odin/OdinObjectDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ protected override void DrawPropertyLayout(GUIContent label)
}

_propertyTree.Update();

if (_propertyTree.ValidationRequired)
{
_propertyTree.RunValidation();
}
_propertyTree.RunValidationIfRequired();

using (TriGuiHelper.PushEditorTarget(ValueEntry.SmartValue))
{
Expand Down
6 changes: 1 addition & 5 deletions Editor.Samples/TriSamplesWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 1 addition & 5 deletions Editor/TriEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@ public override void OnInspectorGUI()
serializedObject.UpdateIfRequiredOrScript();

_inspector.Update();

if (_inspector.ValidationRequired)
{
_inspector.RunValidation();
}
_inspector.RunValidationIfRequired();

using (TriGuiHelper.PushEditorTarget(target))
{
Expand Down
10 changes: 10 additions & 0 deletions Editor/TriPropertyTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ public virtual bool ApplyChanges()
return false;
}

public void RunValidationIfRequired()
{
if (!ValidationRequired)
{
return;
}

RunValidation();
}

public void RunValidation()
{
ValidationRequired = false;
Expand Down

0 comments on commit 513a250

Please sign in to comment.