Version 3.3.1.2

Odin has a dedicated attribute overview with examples

TableMatrixAttribute class

Namespace: Sirenix.OdinInspector
Assembly: Sirenix.OdinInspector.Attributes
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Parameter | AttributeTargets.Delegate | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter | AttributeTargets.All, AllowMultiple = false)]
[Conditional("UNITY_EDITOR")]
public class TableMatrixAttribute : Attribute, _Attribute
The TableMatrix attribute is used to further specify how Odin should draw two-dimensional arrays.
Inheritance
  • System.Object
  • System.Attribute
  • TableMatrixAttribute
Example
// Inheriting from SerializedMonoBehaviour is only needed if you want Odin to serialize the multi-dimensional arrays for you.
// If you prefer doing that yourself, you can still make Odin show them in the inspector using the ShowInInspector attribute.
public class TableMatrixExamples : SerializedMonoBehaviour
{
    [InfoBox("Right-click and drag column and row labels in order to modify the tables."), PropertyOrder(-10), OnInspectorGUI]
    private void ShowMessageAtOP() { }

    [BoxGroup("Two Dimensional array without the TableMatrix attribute.")]
    public bool[,] BooleanTable = new bool[15, 6];

    [BoxGroup("ReadOnly table")]
    [TableMatrix(IsReadOnly = true)]
    public int[,] ReadOnlyTable = new int[5, 5];

    [BoxGroup("Labled table")]
    [TableMatrix(HorizontalTitle = "X axis", VerticalTitle = "Y axis")]
    public GameObject[,] LabledTable = new GameObject[15, 10];

    [BoxGroup("Enum table")]
    [TableMatrix(HorizontalTitle = "X axis")]
    public InfoMessageType[,] EnumTable = new InfoMessageType[4,4];

    [BoxGroup("Custom table")]
    [TableMatrix(DrawElementMethod = "DrawColoredEnumElement", ResizableColumns = false)]
    public bool[,] CustomCellDrawing = new bool[30,30];

    #if UNITY_EDITOR

        private static bool DrawColoredEnumElement(Rect rect, bool value)
        {
            if (Event.current.type == EventType.MouseDown && rect.Contains(Event.current.mousePosition))
            {
                value = !value;
                GUI.changed = true;
                Event.current.Use();
            }

            UnityEditor.EditorGUI.DrawRect(rect.Padding(1), value ? new Color(0.1f, 0.8f, 0.2f) : new Color(0, 0, 0, 0.5f));

            return value;
        }

    #endif
}

Constructors

TableMatrixAttribute()
public TableMatrixAttribute()

Fields

DrawElementMethod
Override how Odin draws each cell.

[TableMatrix(DrawElementMethod='DrawMyElement')]

public MyType[,] myArray;

private static MyType DrawElement(Rect rect, MyType value) { return GUI.DrawMyType(rect, value); }

public string DrawElementMethod
HideColumnIndices
If true, no column indices drawn.
public bool HideColumnIndices
HideRowIndices
If true, no row indices drawn.
public bool HideRowIndices
HorizontalTitle
The horizontal title label.
public string HorizontalTitle
IsReadOnly
If true, inserting, removing and dragging columns and rows will become unavailable. But the cells themselves will remain modifiable. If you want to disable everything, you can use the attribute.
public bool IsReadOnly
Labels
A resolved string that should evaluate to a tuple (string, LabelDirection) which will be used as the label for the rows and columns of the table.
public string Labels
ResizableColumns
Whether or not columns are resizable.
public bool ResizableColumns
RespectIndentLevel
Whether the drawn table should respect the current GUI indent level.
public bool RespectIndentLevel
RowHeight
The height for all rows. 0 = default row height.
public int RowHeight
SquareCells
If true, the height of each row will be the same as the width of the first cell.
public bool SquareCells
Transpose
If true, tables are drawn with rows/columns reversed (C# initialization order).
public bool Transpose
VerticalTitle
The vertical title label.
public string VerticalTitle