Class DisableIfDrawer
Custom PropertyDrawer for the DisableIfAttribute.
Inherited Members
Namespace: Scylla.Core.Editor.Attributes
Assembly: ScyllaCore.Editor.dll
Syntax
[CustomPropertyDrawer(typeof(DisableIfAttribute))]
public sealed class DisableIfDrawer : ConditionalDrawerBase
Remarks
Disables the decorated property field for editing when the condition defined on the
attribute evaluates to true. The field is always visible; it merely becomes
grayed out and non-interactive while the condition holds.
This is the inverse of EnableIfDrawer. Condition evaluation is delegated to EvaluateCondition(SerializedProperty), which supports boolean truthiness checks as well as explicit value comparisons via CompareOperator.
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 full height of the property field regardless of the disabled state, since a disabled field still occupies the same vertical space as an enabled one.
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 height returned by GetPropertyHeight(SerializedProperty, GUIContent, bool) with children included. |
Overrides
OnGUI(Rect, SerializedProperty, GUIContent)
Draws the property field inside a UnityEditor.EditorGUI.DisabledGroupScope when
the condition is true, or normally 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. |