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 [UseOdinInspector] to your class. See following code example:

// Required to tell Databrain it should render UI using Odin Inspector.
[UseOdinInspector]
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<string> myList = new List<string>();

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

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

    public void StateChanged()
    {
        Debug.Log("State changed to " + enumTest);
    }
}

This results in following editor UI:

Note that drawing dictionaries are also supported using Odin Inspector.

Known Issues

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.

Last updated