Unity自定义菜单栏

来源:互联网 发布:软件测试并发测试 编辑:程序博客网 时间:2024/05/21 16:41
using UnityEngine;using System.Collections;using UnityEditor;public class BarCtrl : EditorWindow{    bool groupEnabled;    bool myBool = true;    float myFloat = 1.23f;    Vector3 myVec3 = new Vector3(0, 0, 0);    [MenuItem("MyEditor/Test")]    static void Init()    {        BarCtrl window = (BarCtrl)EditorWindow.GetWindow(typeof(BarCtrl));        window.Show();    }    void OnGUI()//所有的界面都是在这里面进行设置    {        //各种插入        groupEnabled = EditorGUILayout.BeginToggleGroup("Optional Settings", groupEnabled);        myBool = EditorGUILayout.Toggle("MyToggle", myBool);        EditorGUILayout.Space();//中间插入空的一行        myFloat = EditorGUILayout.Slider("Slider", myFloat, -3, 3);        EditorGUILayout.Space();        myVec3 = EditorGUILayout.Vector3Field("myVec3", myVec3);        EditorGUILayout.EndToggleGroup();    }}
以上就是进行自定义菜单的具体操作。欢迎讨论。
0 0
原创粉丝点击