Skip to main content

Class ExtendedScriptableObjectDrawer

Extends how ScriptableObject object references are displayed in the inspector, showing all values under the object reference.

[CustomPropertyDrawer(typeof(ExpandableAttribute), true)]
public class ExtendedScriptableObjectDrawer : PropertyDrawer

Inheritance​

Methods​

CreatePropertyGUI(SerializedProperty)​

Make custom UI Toolkit based GUI for the property.

public override VisualElement CreatePropertyGUI(SerializedProperty property)

Parameters​

NameTypeDescription
propertySerializedPropertyThe SerializedProperty to make the custom GUI for.

Returns​

VisualElement — The element containing the custom GUI.

DrawScriptableObjectField<T>(GUIContent, T, ref bool)​

Draws a simplified ObjectField layout without foldout logic.

public static T DrawScriptableObjectField<T>(GUIContent label, T objectReferenceValue, ref bool isExpanded) where T : ScriptableObject

Parameters​

NameTypeDescription
labelGUIContentGUI label content.
objectReferenceValueTThe object reference to display.
isExpandedboolWhether the content is expanded.

Returns​

T — The edited object reference.

Type Parameters​

NameTypeDescription
TType of ScriptableObject.

GetPropertyHeight(SerializedProperty, GUIContent)​

Specify how tall the GUI for this field is in pixels.

public override float GetPropertyHeight(SerializedProperty property, GUIContent label)

Parameters​

NameTypeDescription
propertySerializedPropertyThe SerializedProperty to make the custom GUI for.
labelGUIContentThe label of this property.

Returns​

float — The height in pixels.

OnGUI(Rect, SerializedProperty, GUIContent)​

Make custom IMGUI based GUI for the property.

public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)

Parameters​

NameTypeDescription
positionRectRectangle on the screen to use for the property GUI.
propertySerializedPropertyThe SerializedProperty to make the custom GUI for.
labelGUIContentThe label of this property.

_GUILayout<T>(string, T, ref bool)​

Creates a foldout-style ObjectField in IMGUI that expands child properties if available.

public static T _GUILayout<T>(string label, T objectReferenceValue, ref bool isExpanded) where T : ScriptableObject

Parameters​

NameTypeDescription
labelstringLabel for the foldout.
objectReferenceValueTReference to the ScriptableObject.
isExpandedboolWhether the foldout is currently expanded.

Returns​

T — The edited object reference.

Type Parameters​

NameTypeDescription
TType of ScriptableObject.

_GUILayout<T>(GUIContent, T, ref bool)​

Creates a foldout-style ObjectField in IMGUI that expands child properties if available.

public static T _GUILayout<T>(GUIContent label, T objectReferenceValue, ref bool isExpanded) where T : ScriptableObject

Parameters​

NameTypeDescription
labelGUIContentLabel for the foldout.
objectReferenceValueTReference to the ScriptableObject.
isExpandedboolWhether the foldout is currently expanded.

Returns​

T — The edited object reference.

Type Parameters​

NameTypeDescription
TType of ScriptableObject.
  • Methods
    • CreatePropertyGUI(SerializedProperty)
    • DrawScriptableObjectField<T>(GUIContent, T, ref bool)
    • GetPropertyHeight(SerializedProperty, GUIContent)
    • OnGUI(Rect, SerializedProperty, GUIContent)
    • _GUILayout<T>(string, T, ref bool)
    • _GUILayout<T>(GUIContent, T, ref bool)