Disable Menu Item
Last updated
Last updated
Use this rule to render some menu items inaccessible.
The specified menu item gets disabled, and won't be clickable.
The disabled menu item is enabled again.
Not all menu items can be disabled. For instance, you can't disable the ones under File or Edit.
This rule is a bit special, in that it doesn't have Inspector properties you can set. This is because the trick used to disable a menu item requires the item to be compiled in code, so it can't be an Inspector property. You will notice that the default one, provided as an example, only ever disables "Window/PackageManager".
The code you need to change is clearly highlighted:
Just change the value of the MenuPath
variable to the item you want to disable.
You can also duplicate that whole block and disable multiple menu items in one go (you need to rename the method to avoid name clashes).
Alternatively, duplicate the script again and repeat the process.
To use this rule, duplicate the DisableMenuItem.cs
script contained in Packages/Hats/Editor/Rules/
, and modify the code inside to include any menu item you need to disable.