Skip to content

Commit 0ee45d5

Browse files
committed
Minor refactor changes
1 parent cf65e6b commit 0ee45d5

2 files changed

Lines changed: 34 additions & 24 deletions

File tree

Assets/Editor Toolbox/Editor/ToolboxPropertyHandler.cs

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -302,29 +302,7 @@ private void BeginDecoratorDrawers(PropertyCondition conditionState = PropertyCo
302302

303303
for (var i = 0; i < decoratorAttributes.Count; i++)
304304
{
305-
var attribute = decoratorAttributes[i];
306-
var drawer = ToolboxDrawerModule.GetDecoratorDrawer(attribute);
307-
if (drawer == null)
308-
{
309-
continue;
310-
}
311-
312-
if (attribute.ApplyCondition)
313-
{
314-
var isValid = conditionState != PropertyCondition.NonValid;
315-
var disable = conditionState == PropertyCondition.Disabled;
316-
if (isValid)
317-
{
318-
using (new EditorGUI.DisabledScope(disable))
319-
{
320-
drawer.OnGuiBegin(attribute);
321-
}
322-
}
323-
}
324-
else
325-
{
326-
drawer.OnGuiBegin(attribute);
327-
}
305+
HandleDecorator(decoratorAttributes[i], true, conditionState);
328306
}
329307
}
330308

@@ -337,7 +315,38 @@ private void CloseDecoratorDrawers(PropertyCondition conditionState = PropertyCo
337315

338316
for (var i = decoratorAttributes.Count - 1; i >= 0; i--)
339317
{
340-
ToolboxDrawerModule.GetDecoratorDrawer(decoratorAttributes[i])?.OnGuiClose(decoratorAttributes[i]);
318+
HandleDecorator(decoratorAttributes[i], false, conditionState);
319+
}
320+
}
321+
322+
private void HandleDecorator(ToolboxDecoratorAttribute attribute, bool onBegin, PropertyCondition conditionState = PropertyCondition.Valid)
323+
{
324+
var drawer = ToolboxDrawerModule.GetDecoratorDrawer(attribute);
325+
if (drawer == null)
326+
{
327+
return;
328+
}
329+
330+
if (!attribute.ApplyCondition)
331+
{
332+
conditionState = PropertyCondition.Valid;
333+
}
334+
335+
var isValid = conditionState != PropertyCondition.NonValid;
336+
var disable = conditionState == PropertyCondition.Disabled;
337+
if (isValid)
338+
{
339+
using (new EditorGUI.DisabledScope(disable))
340+
{
341+
if (onBegin)
342+
{
343+
drawer.OnGuiBegin(attribute);
344+
}
345+
else
346+
{
347+
drawer.OnGuiClose(attribute);
348+
}
349+
}
341350
}
342351
}
343352

Assets/Examples/Scripts/SampleBehaviour2.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public class SampleNestedClass
5252
[Tooltip("Set to 1")]
5353
public int i = 0;
5454
[DisableIf(nameof(i), 1), ReorderableList, TagSelector]
55+
[Help("Nested Information.", ApplyCondition = true)]
5556
public string[] strings;
5657
}
5758

0 commit comments

Comments
 (0)