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

Problem
Solution

DataObject Dropdown property drawer not responding after compilation or when entering play mode.

Deselect and reselect the game object.

Last updated