# Custom GUI with Odin Inspector

Since version 1.1.0 it is now possible to use Odin Inspector attributes to create custom editor UIs. This requires Odin Inspector which is available at the Unity Asset-Store.

To make sure Databrain renders your DataObject class with Odin Inspector support, you will have to add the <mark style="background-color:orange;">\[UseOdinInspector]</mark> to your class. See following code example:

<pre class="language-csharp"><code class="lang-csharp"><strong>// Required to tell Databrain it should render UI using Odin Inspector.
</strong><strong>[UseOdinInspector]
</strong>public class MyOdinDataObject : DataObject
{ 
    [FoldoutGroup("Foldout")] public float foldout1;
    [FoldoutGroup("Foldout")] public float foldout2;
    [FoldoutGroup("Foldout")] public float foldout3;
    
    [AssetList]
    public GameObject prefab;

    [TabGroup("Movement")]
    public float movementSpeed;
    public float rotationSpeed;

    [TabGroup("Properties")]
    public float health;
    public float strength;

    [ColorPalette("Underwater")]
    public Color underwaterColor;

    public enum Test 
    {
        a,
        b,
        c
    }

    [OnValueChanged("StateChanged")]
    [EnumToggleButtons]
    public Test enumTest;

    [ListDrawerSettings(ShowPaging = false)]
    public List&#x3C;string> myList = new List&#x3C;string>();

    [DictionaryDrawerSettings(DisplayMode = DictionaryDisplayOptions.ExpandedFoldout)]
    public Dictionary&#x3C;string, List&#x3C;int>> StringListDictionary = new Dictionary&#x3C;string, List&#x3C;int>>()
    {
        { "Numbers", new List&#x3C;int>(){ 1, 2, 3, 4, } },
    };

    [Button(ButtonSizes.Medium)]
    public void TestMethod()
    {
        Debug.Log("CLICK");
    }

    public void StateChanged()
    {
        Debug.Log("State changed to " + enumTest);
    }
}
</code></pre>

This results in following editor UI:

<div align="left"><figure><img src="/files/zuHU1kacZvae985NR1Ql" alt=""><figcaption></figcaption></figure></div>

{% hint style="info" %}
Note that drawing dictionaries are also supported using Odin Inspector.
{% endhint %}

## Known Issues

{% hint style="warning" %}
Odin Inspector does quite a lot of things in the background regarding editor UI. Odin Inspector takes over the entire rendering of the Unity editor and forces it to render the default Inspector using IMGUI - The legacy UI System of Unity. Databrain has been made using the new UIToolkit system. Odin supports rendering of UIToolkit UI Elements by using a special UITk container inside of IMGUI. While this works quite well, it is still possible that certain issues could arise.
{% endhint %}

| Problem                                                                                          | Solution                               |
| ------------------------------------------------------------------------------------------------ | -------------------------------------- |
| DataObject Dropdown property drawer not responding after compilation or when entering play mode. | Deselect and reselect the game object. |


---

# 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://giantgrey.gitbook.io/databrain/guides/custom-gui-with-odin-inspector.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.
