Class ReadOnlyDrawer
Custom PropertyDrawer for the ReadOnlyAttribute.
Inherited Members
Namespace: Scylla.Core.Editor.Attributes
Assembly: ScyllaCore.Editor.dll
Syntax
[CustomPropertyDrawer(typeof(ReadOnlyAttribute))]
public sealed class ReadOnlyDrawer : PropertyDrawer
Remarks
Renders the property field inside a UnityEditor.EditorGUI.DisabledGroupScope so that it appears grayed out and cannot be edited. This is useful for exposing computed or runtime-only values in the Inspector for debugging purposes without allowing accidental modification.
When RuntimeOnly is true, the field is only
disabled during Play mode (Application.isPlaying == true). In Edit mode it
remains fully editable, which is useful for fields that must be configured at design
time but should be protected from changes once the game is running.
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
GetPropertyHeight(SerializedProperty, GUIContent)
Returns the full height of the property field, including expanded child properties.
Declaration
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
Parameters
| Type | Name | Description |
|---|---|---|
| SerializedProperty | property | The UnityEditor.SerializedProperty to calculate the height for. |
| GUIContent | label | The label of this property. |
Returns
| Type | Description |
|---|---|
| float | The height returned by GetPropertyHeight(SerializedProperty, GUIContent, bool) with children included, identical to what a default drawer would return. |
Overrides
OnGUI(Rect, SerializedProperty, GUIContent)
Draws the property field inside a disabled GUI group, preventing user interaction.
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 in a read-only state. |
| GUIContent | label | The label of this property. |
Overrides
Remarks
Whether the field is actually disabled depends on RuntimeOnly:
when false (the default), the field is always disabled; when true, the
field is disabled only while Application.isPlaying is true.