> For the complete documentation index, see [llms.txt](https://tools.continis.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tools.continis.io/hats/workspaces/workspace-rules/disable-menu-item.md).

# Disable Menu Item

Use this rule to render some menu items inaccessible.

<figure><img src="/files/iPV0ueFGD8Ii2Uf5Tv8a" alt="" width="563"><figcaption></figcaption></figure>

### On workspace enabled

The specified menu item gets disabled, and won't be clickable.

### On workspace disabled

The disabled menu item is enabled again.

{% hint style="warning" %}
Not all menu items can be disabled. For instance, you can't disable the ones under **File** or **Edit**.
{% endhint %}

### Setup

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. The default one, provided as an example, disables the Package Manager menu item (across both Unity 6 and Unity 6.1, where its path differs).

To use this rule, duplicate the `DisableMenuItem.cs` script contained in :open\_file\_folder: `Packages/Hats/Editor/Rules/`, and modify the code inside to include any menu item you need to disable.

The code you need to change is clearly highlighted:

```csharp
// -- Start of customisable block
private const string MenuPath = "Window/Package Manager"; // For Unity 6
private const string MenuPath2 = "Window/My Assets"; // For Unity 6
private const string MenuPath3 = "Window/Package Management/Package Manager"; // For Unity 6.1
private const string MenuPath4 = "Window/Package Management/My Assets"; // For Unity 6.1
private const string MenuPath5 = "Window/Package Management/Services %0"; // For Unity 6.1

[MenuItem(MenuPath, true)]
[MenuItem(MenuPath2, true)]
[MenuItem(MenuPath3, true)]
[MenuItem(MenuPath4, true)]
[MenuItem(MenuPath5, true)]
private static bool ValidateMenuItem() => !_itemIsActive;

// -- End of customisable block
```

Change the value of the `MenuPath` constants to the items you want to disable, and add or remove `[MenuItem(..., true)]` attributes to match.

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.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://tools.continis.io/hats/workspaces/workspace-rules/disable-menu-item.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
