itch.iohttp://itch.iohttps://itch.io/t/2417360/conditionConditionhttps://itch.io/t/2417360/conditionFri, 14 Oct 2022 02:02:59 GMTFri, 14 Oct 2022 02:02:59 GMTFri, 14 Oct 2022 02:02:59 GMTSome Attributes (ShowIf, DisableIf …) use Condition for condition judgment.

Here's how to define Condition 

Property reference

Refer to a property of type Bool, based on the value of the property as the result of the Condition

public bool Switch1;
  
[EnableIf(nameof(Switch1))] 
public int S1;

PlayMode & EditorMode

“@PlayMode” – when application enter play mode, Condition be True

“@EditorMode” – when application exit play mode, Condition be True

[EnableIf(“@PlayMode”)] 
public int S1; 

Other CondtionAttribute reference

One or more ConditionAttributes can be defined on the same property and complex conditional results can be achieved through related references

The syntax of the reference: “@ConditionName”

[ConditionEquals(“S1”, nameof(S1), 2)]
[EnableIf("@S1")]
public int S1_Equals_2;

The above code defines an Equals condition named S1 (to determine whether the property S1 is equal to 2).

 [ConditionHasFlag("F1", nameof(Switch4), EnumFlags.Flag1)] [ConditionHasFlag("F2", nameof(Switch4), EnumFlags.Flag2)] [ConditionOr("Switch4", "@F1", "@F2")] [EnableIf("@Switch4")] public int S4;

Condition “Switch4” = If property Switch4 hasFlag Flag1 or property Switch4  hasFlag Flag2

 

]]>
https://itch.io/t/2417203/sort-and-groupingSort and groupinghttps://itch.io/t/2417203/sort-and-groupingThu, 13 Oct 2022 23:59:43 GMTThu, 13 Oct 2022 23:59:43 GMTThu, 13 Oct 2022 23:59:43 GMTPlugin can sort and group properties, either for the Object property at the top level or for the Nest property set with [ToolkitDrawer] (Refer to Setup section).

Sort

Use [PropertyOrder] to sort 

Example 

public int Value1;
[PropertyOrder(-1)]
public int Value2;
[PropertyOrder(10)]
public int Value3;
public int Value4;

Property

Default order

Actual Order

Value1

1

1

Value2

2

-1

Value3

3

10

Value4

4

4

 Actual display

You can use [ShowPropertyOrder] to display actual order for debug


Grouping

Attributes can be grouped using [BoxGroup], [FoldoutGroup], [TitleGroup], and grouping supports hierarchical

Example

[BoxGroup("Group1")]
public int Value1;
[BoxGroup("Group1")]
public int Value2;
 
[FoldoutGroup("Group2", ScopeType = GroupScopeType.ScopeBegin)]
public float Value3;
public float Value3_2;
[TitleGroup("Group2/Panel")]
public float Value4;
public float Value4_2;
[FoldoutGroup("Group2", ScopeType = GroupScopeType.ScopeEnd)]
public float Value5;
 
[BoxGroup("Group1")]
public int Value2_1;
 
public int Value101;

Group info

Group

Property

Group1

Value1

 

Value2

 

Value2_1

Group2

Value3

 

Value3_2

Group2/Panel

Value4

Group2

Value4_2

Group2

Value5

[Root]

Value101

 Actual display

Explain

  • Properties all have belonging a group, if there is no [XXXGroup], it belongs to [Root]
  • Group can set up a parent group through the path(similar to g1/g2/g3).
  • The Group determines the scope of action via scopeType, which defaults to Single. Just the current property that are applied
    • ScopeBegin: indicates that a range is applied, and subsequent properties are considered within the scope if there is no [XXXGroup]. Automatically assign to Group
    • ScopeEnd: indicates that a range is end Group's order was determined by the PropertyOrder of the first Property
]]>