Class LayerFieldDrawer
Custom PropertyDrawer for the LayerFieldAttribute.
Inherited Members
Namespace: Scylla.Core.Editor.Attributes
Assembly: ScyllaCore.Editor.dll
Syntax
[CustomPropertyDrawer(typeof(LayerFieldAttribute))]
public sealed class LayerFieldDrawer : PropertyDrawer
Remarks
Replaces the default integer field with Unity's built-in layer selection popup, allowing
designers to pick a physics or rendering layer by name instead of entering a raw integer.
The decorated field must be of type int; applying the attribute to any other field
type renders an error UnityEditor.MessageType.Error help box instead.
The selected layer is stored as its integer layer index (0-31), which is directly
compatible with Unity's LayerMask utilities and gameObject.layer.
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
OnGUI(Rect, SerializedProperty, GUIContent)
Draws a layer selection dropdown that lets the user pick a Unity layer by name.
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 draw. Must be of type UnityEditor.SerializedPropertyType.Integer; otherwise an error help box is rendered and no value is written. |
| GUIContent | label | The label to display to the left of the dropdown. |
Overrides
Remarks
Changes are detected with UnityEditor.EditorGUI.BeginChangeCheck() / UnityEditor.EditorGUI.EndChangeCheck() so that Undo/Redo and the dirty-marking system work correctly.