using UnityEditor; using UnityEngine; public enum MyType { Dev, Master } public class TestCode : MonoBehaviour { public string testStr; public bool isTest; public MyType myType; public float testNum; } [CustomEditor(typeof(TestCode))] public class TestCodeHelp : Editor { public override void OnInspectorGUI() { //此处映射上面的字段 EditorGUILayout.PropertyField(serializedObject.FindProperty("testStr"), new GUIContent("测试字符串")); EditorGUILayout.PropertyField(serializedObject.FindProperty("isTest"), new GUIContent("是否测试")); EditorGUILayout.PropertyField(serializedObject.FindProperty("myType"), new GUIContent("类型")); EditorGUILayout.PropertyField(serializedObject.FindProperty("testNum"), new GUIContent("数字")); //绘制按钮 if (GUILayout.Button("Step1: Play Scene")) { Debug.Log("test === "); } } }
标签:自定义,GUIContent,FindProperty,serializedObject,new,Inspector,面板,PropertyField,publ From: https://www.cnblogs.com/sanyejun/p/17183205.html