Class SceneFieldDrawer
Custom PropertyDrawer for the SceneFieldAttribute.
Inherited Members
Namespace: Scylla.Core.Editor.Attributes
Assembly: ScyllaCore.Editor.dll
Syntax
[CustomPropertyDrawer(typeof(SceneFieldAttribute))]
public sealed class SceneFieldDrawer : PropertyDrawer
Remarks
Replaces the default string field with a popup dropdown listing all enabled scenes
from the Unity Build Settings. The stored value is the scene file name without extension,
which can be passed directly to SceneManager.LoadScene(string).
If the string currently stored in the property does not match any scene in the Build
Settings list, it is shown at the top of the dropdown with a " (Missing)"
suffix so that the misconfiguration is immediately visible. Selecting a valid scene
from the list removes the suffix and stores the clean name.
When no scenes are present in the Build Settings at all, a warning help box is shown
in place of the dropdown. The decorated field must be of type string; applying
the attribute to any other type renders an error help box.
The scene list is cached and only rebuilt when the Build Settings change, using a hash of scene paths and enabled states to detect modifications.
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 the scene selection dropdown, populating it with all enabled scenes from Build Settings.
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. When no scenes exist in Build Settings, a warning help box is rendered instead of the dropdown. |
| GUIContent | label | The label to display above the dropdown in the Inspector. |