Skip to main content

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​

Methods​

CreatePropertyGUI(SerializedProperty)​

Creates the VisualElement-based UI for the property.

public override VisualElement CreatePropertyGUI(SerializedProperty property)

Parameters​

NameTypeDescription
propertySerializedPropertySerialized 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​

NameTypeDescription
propertySerializedPropertyThe condition property's serialized data.
ifAttributeEnableIfAttributeThe 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​

NameTypeDescription
positionRectThe rectangle on screen to use for the property field.
propertySerializedPropertyThe property to draw.
labelGUIContentLabel to display beside the property.
  • Methods
    • CreatePropertyGUI(SerializedProperty)
    • GetCurrentState(SerializedProperty, EnableIfAttribute)
    • OnGUI(Rect, SerializedProperty, GUIContent)