Class DisableIfAttributeDrawer
Custom property drawer for the DisableIfAttribute, responsible for disabling a field in the Unity Inspector based on the evaluation of one or more conditions.
[CustomPropertyDrawer(typeof(DisableIfAttribute))]
public class DisableIfAttributeDrawer : EnableIfAttributeDrawer
Inheritance
Inherited Members
- EnableIfAttributeDrawer.CreatePropertyGUI(SerializedProperty)
- EnableIfAttributeDrawer.UpdateState(SerializedProperty, VisualElement)
- EnableIfAttributeDrawer.GetCurrentState(SerializedProperty, EnableIfAttribute)
- EnableIfAttributeDrawer.OnGUI(Rect, SerializedProperty, GUIContent)
Methods
CreatePropertyGUI(SerializedProperty)
Creates the VisualElement-based UI for the property.
public override VisualElement CreatePropertyGUI(SerializedProperty property)
Parameters
| Name | Type | Description |
|---|---|---|
property | SerializedProperty | Serialized property being drawn. |
Returns
VisualElement — The element containing the custom GUI.
GetCurrentState(SerializedProperty, EnableIfAttribute)
Evaluates the condition state to determine how should the property be handled.
protected override bool GetCurrentState(SerializedProperty property, EnableIfAttribute ifAttribute)
Parameters
| Name | Type | Description |
|---|---|---|
property | SerializedProperty | The condition property's serialized data. |
ifAttribute | EnableIfAttribute | The EnableIfAttribute instance containing condition metadata. |
Returns
bool — The current state.
OnGUI(Rect, SerializedProperty, GUIContent)
Draws the IMGUI-based field in the Inspector.
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
Parameters
| Name | Type | Description |
|---|---|---|
position | Rect | The rectangle on screen to use for the property field. |
property | SerializedProperty | The property to draw. |
label | GUIContent | Label to display beside the property. |