Skip to main content

Class HideIfAttribute

Attribute used to conditionally hide a property in the Unity Inspector. Inverse of ShowIfAttribute.

public class HideIfAttribute : ShowIfAttribute

Inheritance​

Inherited Members​

Examples​

Hide a field when the "ShouldHide" bool is true:

public bool ShouldHide;
[ShowIf(nameof(ShouldHide))]
public int SomeValue;

Remarks​

Use this to hide fields when certain boolean conditions are met.

Constructors​

HideIfAttribute(string, int)​

Creates a new instance of HideIfAttribute with a single condition.

public HideIfAttribute(string conditionName, int order = 0)

Parameters​

NameTypeDescription
conditionNamestringThe name of the boolean property that controls visibility.
orderintThe drawer order for rendering (optional).

HideIfAttribute(EConditionOperator, int, params string[])​

Creates a new instance of HideIfAttribute with multiple conditions.

public HideIfAttribute(EConditionOperator operatorType, int order = 0, params string[] conditionNames)

Parameters​

NameTypeDescription
operatorTypeEConditionOperatorLogical operator used to evaluate multiple conditions.
orderintThe drawer order for rendering (optional).
conditionNamesstring[]An array of condition property names.