While it's common knowledge that we can create an Editor menu item in an Editor script with the [MenuItem]
attribute, a lesser-known ability is being able to set custom hotkeys for menu items. For example, we can make the
K
key trigger our menu item method by defining the [MenuItem]
attribute ending with _k
as follows:
[MenuItem("My Menu/Menu Item _k")]
We can also include modifier keys such as Ctrl (Command), Shift, and Alt using the %
, #
, and &
characters, respectively.
[MenuItem]
also has two overloads, which allows us to set two additional parameters: a Boolean that determines whether the menu item requires a validation method, and an integer that determines the menu item's priority in the Hierarchy
window.
Check out the documentation for [MenuItems]
for a complete list of available hotkey modifiers, special keys, and how to create validation methods at http://docs.unity3d.com/ScriptReference/MenuItem.html.
It is possible to ping an object in the Hierarchy...