using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEngine.Rendering.PostProcessing;public class AutoGenerateWindow : EditorWindow //这是定义一个窗口
{public string subjecttName = "科目名字";//科目的名字public GameObject modelAsset;//模型AutoGenerateWindow(){this.titleContent = new GUIContent("自动生成");}private void OnEnable(){//控制弹出窗口的高度this.maxSize = new Vector2(500, 200);this.minSize = new Vector2(500, 200);}[MenuItem("自动生成/打开生成面板")] //这是在添加菜单栏的按钮private static void OnOpenGeneateWindow(){AutoGenerateWindow win = EditorWindow.GetWindow<AutoGenerateWindow>();win.Show();//打开这个窗口}private void OnGUI(){//添加属性GUILayout.Space(10);//每个属性之间上下的空白subjecttName = EditorGUILayout.TextField("科目名字", subjecttName);modelAsset = (GameObject)EditorGUILayout.ObjectField("模型", modelAsset, typeof(GameObject), false); //最后的bool,true选择scene里的物体,false资源选择器//添加按钮if (GUILayout.Button("生成")){//点击按钮的具体逻辑}}
}
打开的窗口如下