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
// 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
}
public TableMatrixAttribute()
[TableMatrix(DrawElementMethod='DrawMyElement')]
public MyType[,] myArray;
private static MyType DrawElement(Rect rect, MyType value) { return GUI.DrawMyType(rect, value); }
public string DrawElementMethod
public bool HideColumnIndices
public bool HideRowIndices
public string HorizontalTitle
public bool IsReadOnly
public string Labels
public bool ResizableColumns
public bool RespectIndentLevel
public int RowHeight
public bool SquareCells
public bool Transpose
public string VerticalTitle