# Building Hats-based tools

In addition to the built-in functionality, Hats provides API so you can create tools that provide a tailored experienced to their users.

## How to create your own tool

In general, the idea is to create tools (or, more specifically, their UI) that looks or acts differently based on which Team or Workspace is enabled.

This usually requires two steps:

1. Define which Workspace or Team to look for. You can either:
   * Hardcode the information in C#.
   * Allow the user to choose from a UI, using a Dropdown or some other control that allows to specify what to look for (see [UI elements](#ui-elements) below). This way you would be creating a tool that the user can configure for themselves.
2. Use this information to tweak the tool's behaviour, by using Hats' [public API](#api).

{% hint style="info" %}
For instance, in the custom Inspector for a component, one could display or hide parts of it based on whether the user is part of a specific Team.
{% endhint %}

## UI elements

To facilitate the task of creating tools, Hats comes with UI Elements that you can use in your UIs to allow the user to choose a workspace or a Team.

{% hint style="danger" %}
The built-in UI elements are only available for **UI Toolkit**. For IMGUI components, you will need to build them yourself.
{% endhint %}

### Team Picker Dropdown

This UI automatically displays existing teams in a dropdown. Like other `MaskField` in Unity, the value is stored as an `int` bitmask, where 0 means no Team, and -1 means all Teams.

To use it, add an element of class `TeamPickerDropdown` to your UIs.

<figure><img src="/files/UW5A7ywSqq7efCW8HyGH" alt="" width="393"><figcaption><p>The TeamPickerDropdown in action</p></figcaption></figure>

{% hint style="info" %}
The constructor allows to pass a `bool` parameter to visualise the No Teams option or to hide it. This can be used to ensure that at least a Team is selected.
{% endhint %}

### Workspace Selector UI

{% hint style="info" %}
A workspace selector UI will come in a future version of Hats.
{% endhint %}

## API

Hats provides a host of public API to query the current state of workspaces and Teams.

Look into the static classes `Workspaces` and `Teams` in the `Hats.Editor` namespace for the full list of public API.


---

# 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/building-on-hats/building-hats-based-tools.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.
