Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Condition

A topic by CatyboyStudio created Oct 14, 2022 Views: 52
Viewing posts 1 to 1

Some 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