首先在Editor 文件夹下创建脚本
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
namespace RunAndJump.LevelCreator
{
//创建自定义编辑器窗体 需要继承EditorWindow
public class PaletteWindow : EditorWindow
{
//自定义窗体一般用单例模式
#region Singleton
private static PaletteWindow instance;
public static void ShowPalette()
{
instance = EditorWindow.GetWindow<PaletteWindow>(); //GetWindow(typeof(PaletteWindow))
//设置窗体标题
instance.titleContent = new GUIContent("Palette");
}
#endregion
}
}
然后在Scripts文件夹下,创建菜单栏选项
[MenuItem("Tools/Level Creator/Show Palette")]
private static void ShowPalette()
{
PaletteWindow.ShowPalette();
}
可以得到如下图所示效果