The doc have this information in them:
Validated menu item.
// Add a menu item named "Log Selected Transform Name" to MyMenu in the menu bar.
// We use a second function to validate the menu item
// so it will only be enabled if we have a transform selected.
[MenuItem("MyMenu/Log Selected Transform Name")]
static void LogSelectedTransformName()
{
Debug.Log("Selected Transform is on " + Selection.activeTransform.gameObject.name + ".");
}
// Validate the menu item defined by the function above.
// The menu item will be disabled if this function returns false.
[MenuItem("MyMenu/Log Selected Transform Name", true)]
static bool ValidateLogSelectedTransformName()
{
// Return false if no transform is selected.
return Selection.activeTransform != null;
}
I create code following the above example. However, the MenuItem does not show as “disabled if this function returns false”, I thought that by disabled the menu item would at least be grayed out. Was I wrong in assuming that? And how do I grey out a MenuItem then?