Unity自定义菜单栏

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();

    }
}
以上就是进行自定义菜单的具体操作。欢迎讨论。

你可能感兴趣的:(Unity学习日志)