Version: Unity 6.3 Beta (6000.3)
LanguageEnglish
  • C#

InspectorElement.FillDefaultInspector

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public static void FillDefaultInspector(UIElements.VisualElement container, SerializedObject serializedObject, Editor editor);

Parameters

Parameter Description
container The parent VisualElement
serializedObject The SerializedObject to inspect
editor The editor currently used

Description

Adds default inspector property fields under a container VisualElement.

The following example shows how to fill a container with default inspector fields. For a complete example, refer to Create a default Inspector.

using UnityEditor;
using UnityEditor.UIElements;
using UnityEngine;
using UnityEngine.UIElements;

[CreateAssetMenu] public class MyEditorData : ScriptableObject { public string myString; public float myFloat; public string myInt; }

[CustomEditor(typeof(MyEditorData))] public class MyEditor : UnityEditor.Editor { public override VisualElement CreateInspectorGUI() { var root = new VisualElement(); root.Add(new Label("My Custom Inspector")); InspectorElement.FillDefaultInspector(root, serializedObject, this); return root; } }

Declaration

public static void FillDefaultInspector(UIElements.VisualElement container, SerializedObject serializedObject, Editor editor, params string[] propertiesToExclude);

Parameters

Parameter Description
container The parent VisualElement.
serializedObject The SerializedObject to inspect.
editor The Editor currently used.
propertiesToExclude Properties to exclude when populating the Inspector. Properties with name matching SerializedProperty.name are skipped.

Description

Adds default inspector property fields under a container VisualElement.

The following example shows how to fill a container with default Inspector fields. For a complete example, refer to Create a default Inspector.

using UnityEditor;
using UnityEditor.UIElements;
using UnityEngine;
using UnityEngine.UIElements;

[CreateAssetMenu] public class MyEditorData : ScriptableObject { public string myString; public float myFloat; public string myInt; }

[CustomEditor(typeof(MyEditorData))] public class MyEditor : UnityEditor.Editor { public override VisualElement CreateInspectorGUI() { var root = new VisualElement(); root.Add(new Label("My Custom Inspector")); InspectorElement.FillDefaultInspector(root, serializedObject, this); return root; } }

The following example shows how to fill a container with default Inspector fields, excluding a specific property that is displayed as a Slider.

using UnityEditor;
using UnityEditor.UIElements;
using UnityEngine;
using UnityEngine.UIElements;

[CreateAssetMenu] public class MyEditorDataExclude : ScriptableObject { public string myString; public float myFloat; public string myInt; }

[CustomEditor(typeof(MyEditorDataExclude))] public class MyEditorExclude : UnityEditor.Editor { public override VisualElement CreateInspectorGUI() { var root = new VisualElement(); root.Add(new Label("My Custom Inspector"));

var myFloatSlider = new Slider { bindingPath = "myFloat", label = "My Float" }; root.Add(myFloatSlider);

// Draw all properties except "myFloat" InspectorElement.FillDefaultInspector(root, serializedObject, this, "myFloat"); return root; } }