Custom editors/menus tips
We can set custom hotkeys for MenuItems. For example, we can make the K key trigger our Menu item method, by defining the MenuItem
attribute as follows:
[MenuItem("My Menu/Menu Item _k")]
We can also include modifier keys such as Ctrl (Cmd), Shift, and Alt using the %, #, and & characters, respectively.
MenuItems also have 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.
Check the documentation for MenuItems for a complete list of available hotkey modifiers, special keys, and how to create validation methods:
Get Unity 5 Game Optimization now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.