Class ShowIfDrawer
Custom PropertyDrawer for the ShowIfAttribute.
Inherited Members
Namespace: Scylla.Core.Editor.Attributes
Assembly: ScyllaCore.Editor.dll
Syntax
[CustomPropertyDrawer(typeof(ShowIfAttribute))]
public sealed class ShowIfDrawer : ConditionalDrawerBase
Remarks
Shows the decorated property field only when the condition defined on the attribute
evaluates to true. When the condition is false, the field is completely
hidden and takes up no vertical space in the Inspector (no gap is left behind).
This is the inverse of HideIfDrawer. 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.
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 true; draws nothing
when the condition is false.
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. |