# 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. You will notice that the default one, provided as an example, only ever disables "Window/PackageManager".

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";
        
[MenuItem(MenuPath, true)]
private static bool ValidateMenuItem() => !_itemIsActive;

// -- End of customisable block
```

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.


---

# Agent Instructions: 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.
