using UnityEngine; using System.Collections; using UnityEditor; public class MYGUI : MonoBehaviour { [MenuItem("MYGUI/Creat/Window")] public static void CreatWindow() { EditorWindow.GetWindow<MyWindow>(true, "MYGUI", true); } }
using UnityEngine; using System.Collections; using UnityEditor; public class MyWindow : EditorWindow { string defaultString = "请选择"; bool groupEnabled; bool myBool = true; //float myFloat = 1.23f; //下拉按钮数量 int buttonNum; //下拉按钮宽高背景图片深度 float buttonWidth; float buttonHeight; SpriteSelector sprite; static void Init() { } void OnGUI() { GUILayout.Label("下拉菜单", EditorStyles.boldLabel); defaultString = EditorGUILayout.TextField("默认文字", defaultString); GUILayout.Label("下拉按钮", EditorStyles.boldLabel); buttonNum = EditorGUILayout.IntField("数量", buttonNum); GUILayout.Label("背景", EditorStyles.boldLabel); GUILayout.BeginHorizontal(); ComponentSelector.Draw<UIAtlas>(NGUISettings.atlas, OnSelectAtlas, GUILayout.Width(140f)); GUILayout.Label("修改", GUILayout.MinWidth(10000f)); GUILayout.EndHorizontal(); //groupEnabled = EditorGUILayout.BeginToggleGroup("设置", groupEnabled); //myBool = EditorGUILayout.Toggle("Toggle", myBool); //myFloat = EditorGUILayout.Slider("Slider", myFloat, -3, 3); //EditorGUILayout.EndToggleGroup(); } void OnSelectAtlas(MonoBehaviour obj) { NGUISettings.atlas = obj as UIAtlas; Repaint(); } }