Skip to content

Commit 513a250

Browse files
committed
Add RunValidationIfRequired api
1 parent db3d602 commit 513a250

File tree

5 files changed

+14
-20
lines changed

5 files changed

+14
-20
lines changed

Editor.Integrations/Odin/OdinFieldDrawer.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,7 @@ protected override void DrawPropertyLayout(GUIContent label)
6666
}
6767

6868
_propertyTree.Update();
69-
70-
if (_propertyTree.ValidationRequired)
71-
{
72-
_propertyTree.RunValidation();
73-
}
69+
_propertyTree.RunValidationIfRequired();
7470

7571
_labelOverrideContext.Label = label ?? GUIContent.none;
7672

Editor.Integrations/Odin/OdinObjectDrawer.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,7 @@ protected override void DrawPropertyLayout(GUIContent label)
6565
}
6666

6767
_propertyTree.Update();
68-
69-
if (_propertyTree.ValidationRequired)
70-
{
71-
_propertyTree.RunValidation();
72-
}
68+
_propertyTree.RunValidationIfRequired();
7369

7470
using (TriGuiHelper.PushEditorTarget(ValueEntry.SmartValue))
7571
{

Editor.Samples/TriSamplesWindow.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,7 @@ private void DrawElement()
9494

9595
_currentSerializedObject.UpdateIfRequiredOrScript();
9696
_currentPropertyTree.Update();
97-
98-
if (_currentPropertyTree.ValidationRequired)
99-
{
100-
_currentPropertyTree.RunValidation();
101-
}
97+
_currentPropertyTree.RunValidationIfRequired();
10298

10399
GUILayout.Space(10);
104100
GUILayout.Label("Preview", EditorStyles.boldLabel);

Editor/TriEditor.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,7 @@ public override void OnInspectorGUI()
5353
serializedObject.UpdateIfRequiredOrScript();
5454

5555
_inspector.Update();
56-
57-
if (_inspector.ValidationRequired)
58-
{
59-
_inspector.RunValidation();
60-
}
56+
_inspector.RunValidationIfRequired();
6157

6258
using (TriGuiHelper.PushEditorTarget(target))
6359
{

Editor/TriPropertyTree.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ public virtual bool ApplyChanges()
4040
return false;
4141
}
4242

43+
public void RunValidationIfRequired()
44+
{
45+
if (!ValidationRequired)
46+
{
47+
return;
48+
}
49+
50+
RunValidation();
51+
}
52+
4353
public void RunValidation()
4454
{
4555
ValidationRequired = false;

0 commit comments

Comments
 (0)