Class HideIfDrawer
Custom PropertyDrawer for the HideIfAttribute.
Inherited Members
Namespace: Scylla.Core.Editor.Attributes
Assembly: ScyllaCore.Editor.dll
Syntax
[CustomPropertyDrawer(typeof(HideIfAttribute))]
public sealed class HideIfDrawer : ConditionalDrawerBase
Remarks
Hides the decorated property field when the condition defined on the attribute evaluates
to true. When the condition is false, the field is shown normally with
its standard height and spacing.
This is the inverse of ShowIfDrawer. Condition evaluation is delegated to EvaluateCondition(SerializedProperty), which supports boolean truthiness checks as well as explicit value comparisons via CompareOperator.
To eliminate the automatic spacing Unity adds between properties when a property
returns zero height, GetPropertyHeight(SerializedProperty, GUIContent) returns
-EditorGUIUtility.standardVerticalSpacing rather than 0 when the
field is hidden.
Methods
CreatePropertyGUI(SerializedProperty)
Creates custom GUI with UI Toolkit for the property.
Declaration
public override VisualElement CreatePropertyGUI(SerializedProperty property)
Parameters
| Type | Name | Description |
|---|---|---|
| SerializedProperty | property | The SerializedProperty to make the custom GUI for. |
Returns
| Type | Description |
|---|---|
| VisualElement | The element containing the custom GUI. |
Overrides
GetPropertyHeight(SerializedProperty, GUIContent)
Returns the height of the property when visible, or a negative offset to suppress Unity's automatic spacing when the property is hidden.
Declaration
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
Parameters
| Type | Name | Description |
|---|---|---|
| SerializedProperty | property | The UnityEditor.SerializedProperty to calculate the height for. |
| GUIContent | label | The label of this property. |
Returns
| Type | Description |
|---|---|
| float | The full property height (including children) when the condition is |
Overrides
OnGUI(Rect, SerializedProperty, GUIContent)
Draws the property field when the condition evaluates to false; draws nothing
when the condition is true.
Declaration
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | position | Rectangle on the screen to use for the property GUI. |
| SerializedProperty | property | The UnityEditor.SerializedProperty to make the custom GUI for. |
| GUIContent | label | The label of this property. |