Créez d'abord un script dans le dossier 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
}
}
Ensuite, sous le dossier Scripts, créez une option de barre de menus
[MenuItem("Tools/Level Creator/Show Palette")]
private static void ShowPalette()
{
PaletteWindow.ShowPalette();
}
Vous pouvez obtenir l'effet comme indiqué dans la figure ci-dessous