Class TagFieldDrawer
Custom PropertyDrawer for the TagFieldAttribute.
Inherited Members
Namespace: Scylla.Core.Editor.Attributes
Assembly: ScyllaCore.Editor.dll
Syntax
[CustomPropertyDrawer(typeof(TagFieldAttribute))]
public sealed class TagFieldDrawer : PropertyDrawer
Remarks
Replaces the default string field with Unity's built-in tag selection popup, allowing
designers to choose a tag by name from the project's defined tag list instead of
typing a raw string. The stored value is the tag name string, which is directly
compatible with GameObject.CompareTag and GameObject.tag.
The decorated field must be of type string; applying the attribute to
any other type renders an error help box.
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 tag selection dropdown using Unity's built-in TagField(Rect, string).
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.String; 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. The property stores the selected tag's name string.