Class HideIfAttribute
Attribute used to conditionally hide a property in the Unity Inspector. Inverse of ShowIfAttribute.
public class HideIfAttribute : ShowIfAttribute
Inheritance
Inherited Members
- EnableIfAttribute.ConditionNames
- EnableIfAttribute.Operator
- EnableIfAttribute.GetCondition(SerializedProperty)
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
| Name | Type | Description |
|---|---|---|
conditionName | string | The name of the boolean property that controls visibility. |
order | int | The 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
| Name | Type | Description |
|---|---|---|
operatorType | EConditionOperator | Logical operator used to evaluate multiple conditions. |
order | int | The drawer order for rendering (optional). |
conditionNames | string[] | An array of condition property names. |