Editor.CreateInspectorGUI

声明

public UIElements.VisualElement CreateInspectorGUI();

描述

实现此方法以创建自定义 UIElements 检查器。

在此方法中,您可以为特定对象类创建自己的自定义 UIElements 检查器。

注意: 此函数必须被重写才能生效。

以下示例展示了如何使用 override 创建自定义标签。

using UnityEngine;
using System.Collections;
using UnityEditor;

// Creates a custom Label on the inspector for all the scripts named ScriptName // Make sure you have a ScriptName script in your // project, else this will not work. [CustomEditor(typeof(ScriptName))] public class TestOnInspector : Editor { public override VisualElement CreateInspectorGUI() { return new Label("This is a Label in a Custom Editor"); } }

Did you find this page useful? Please give it a rating: