//把该脚本放在Editor下
可在unity菜单栏可看到结果:
% – CTRL on Windows / CMD on OSX
# – Shift
& – Alt
LEFT/RIGHT/UP/DOWN – Arrow keys
F1…F2 – F keys
HOME, END, PGUP, PGDN
public class CustomMenu {
#region 自定义菜单栏
[MenuItem("Tool/test/Clear Data")]
private static void MenuTest()
{
PlayerPrefs.DeleteAll();
}
#endregion
#region 自定义热键
[MenuItem("tool/item %g")]
private static void NewOption()
{
Debug.Log("1");
}
[MenuItem("tool/item _g")]
private static void NewOption1()
{
}
#endregion
#region 测试
[MenuItem("Assets/Create/Add Configuration")]
private static void AddConfig()
{
// Create and add a new ScriptableObject for storing configuration
}
// Add a new menu item that is accessed by right-clicking inside the RigidBody component
[MenuItem("CONTEXT/Rigidbody/New Option")]
private static void NewOpenForRigidBody()
{
}
#endregion
#region 自定义选项 优先级 1,2,
[MenuItem("NewMenu/Option1", false, 65)]
private static void NewMenuOption()
{
}
[MenuItem("NewMenu/Option2", false, 2)]
private static void NewMenuOption2()
{
}
[MenuItem("NewMenu/Option3", false, 3)]
private static void NewMenuOption3()
{
}
[MenuItem("NewMenu/Option4", false, 51)]
private static void NewMenuOption4()
{
}
[MenuItem("NewMenu/Option5", false, 52)]
private static void NewMenuOption5()
{
}
#endregion
#region
#endregion
}
//自定义inspector
using UnityEngine;
using System.Collections;
public class CustomRandom : MonoBehaviour {
[ContextMenuItem("Randomize Name", "Randomize")]
public string Name;
private void Randomize()
{
Name = "Some Random Name";
}
}