Skip to main content

Class SerializeReferenceEditorGUI

Namespace: Aspid.FastTools.SerializeReferences.Editors
Assembly: Aspid.FastTools.Editor.dll

Provides utility methods for drawing managed-reference type pickers in custom inspectors.

public static class SerializeReferenceEditorGUI

Inheritance​

object ← SerializeReferenceEditorGUI

Remarks​

Use SerializeReferenceEditorGUI.CreateField and SerializeReferenceEditorGUI.CreateList in CreateInspectorGUI, and SerializeReferenceEditorGUI.DrawFieldLayout in OnInspectorGUI.

Methods​

CreateField(SerializedProperty, string, params Type[])​

Creates a UI Toolkit type picker with nested fields and managed-reference notices.

public static VisualElement CreateField(SerializedProperty property, string label = null, params Type[] baseTypes)

Parameters​

property SerializedProperty

A managed-reference property of the editor's SerializedObject.

label string

property label; null uses its display name.

baseTypes Type[]

Extra base types every candidate must be assignable to besides the field type; null or an empty array adds none.

Returns​

VisualElement

The field to add to the inspector's visual tree.

Exceptions​

ArgumentNullException

property is null.

ArgumentException

property is not a managed reference.

CreateList(SerializedProperty, string, params Type[])​

Creates a UI Toolkit managed-reference list whose add button selects a type and appends an independent instance.

public static VisualElement CreateList(SerializedProperty property, string label = null, params Type[] baseTypes)

Parameters​

property SerializedProperty

An array/list property whose elements are managed references.

label string

property header label; null uses its display name.

baseTypes Type[]

Extra base types every element type must be assignable to besides the declared one; null or an empty array adds none.

Returns​

VisualElement

The list to add to the inspector's visual tree.

Exceptions​

ArgumentNullException

property is null.

ArgumentException

property is not a managed-reference array.

DrawFieldLayout(SerializedProperty, GUIContent, params Type[])​

Draws a managed-reference type picker and its nested fields in an IMGUI layout.

public static void DrawFieldLayout(SerializedProperty property, GUIContent label = null, params Type[] baseTypes)

Parameters​

property SerializedProperty

A managed-reference property of the editor's SerializedObject.

label GUIContent

property label; null uses its display name.

baseTypes Type[]

Extra base types every candidate must be assignable to besides the field type; null or an empty array adds none.

Remarks​

Lists use SerializeReferenceIMGUIList.Draw.

Exceptions​

ArgumentNullException

property is null.

ArgumentException

property is not a managed reference.