Version: 2022.2

Editor.DrawDefaultInspector

切换到手册
public bool DrawDefaultInspector ();

描述

绘制内置检视面板。

在 OnInspectorGUI 方法中调用此方法可自动绘制检视面板。 如果要添加一些按钮而不必重新绘制整个检视面板,这会非常有用。 另请参阅:OnInspectorGUI

// This example shows a custom inspector for an
// object "MyPlayer", which has a variable speed.
using UnityEngine;
using UnityEditor;
using System.Collections;

[CustomEditor(typeof(MyPlayer))] public class Example : Editor { public override void OnInspectorGUI() { MyPlayer targetPlayer = (MyPlayer)target; EditorGUILayout.LabelField ("Some help", "Some other text");

targetPlayer.speed = EditorGUILayout.Slider ("Speed", targetPlayer.speed, 0, 100);

// Show default inspector property editor DrawDefaultInspector (); } }