Class ConditionalDrawerBase
Base class for conditional UnityEditor.PropertyDrawer implementations that show, hide, enable, or disable a field based on the value of another field on the same object.
Inheritance
Inherited Members
Namespace: Scylla.Core.Editor.Attributes
Assembly: ScyllaCore.Editor.dll
Syntax
public abstract class ConditionalDrawerBase : PropertyDrawer
Remarks
Provides the shared EvaluateCondition(SerializedProperty) method used by ShowIfDrawer, HideIfDrawer, EnableIfDrawer, and DisableIfDrawer.
Condition evaluation resolves the named sibling field referenced by ConditionField using a path-aware search that correctly handles nested serialized objects and array elements. The resolved property value is then compared against CompareValue using the CompareOperator specified on the attribute.
When no compare value is provided (i.e., the compare value is null), the
condition is evaluated as a boolean truthiness check, where zero, empty string, null
object reference, and zero-index enum all evaluate to false.
If the named condition field cannot be found, a warning is logged to the console and
the condition defaults to true so that the decorated field remains visible.
Methods
EvaluateCondition(SerializedProperty)
Evaluates the condition defined by the ConditionalAttributeBase attached to this drawer by locating the referenced field and comparing its value.
Declaration
protected bool EvaluateCondition(SerializedProperty property)
Parameters
| Type | Name | Description |
|---|---|---|
| SerializedProperty | property | The property currently being drawn. Used to resolve the path to sibling properties on the same serialized object, including handling nested objects and array elements. |
Returns
| Type | Description |
|---|---|
| bool |
|