bool 如果默认 Inspector 中的任何 GUI 控件更改了输入数据的的值,则返回 true,否则返回 false。
绘制内置 Inspector。
在 OnInspectorGUI 方法中调用此方法以自动绘制 Inspector。如果您想添加一些按钮,而无需重新执行整个 Inspector,这将很有用。其他资源:OnInspectorGUI.
// This example shows a custom inspector for an // object "MyPlayer", which has a variable speed. using UnityEngine; using UnityEditor;
class MyPlayer : MonoBehaviour { // Hide this field so that it is not shown twice when drawing the default Inspector. [HideInInspector] public float speed;
public int gear; }
[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 if(DrawDefaultInspector()) Debug.Log("Gear was changed!"); } }