Make [TableMatrix] allow controlling the height of squared cells

Issue #667 new
Tor Esa Vestergaard created an issue

The RowHeight and SquareCells arguments currently conflict with and override each other, because SquareCells makes the cells square by changing the height based on the width.

Repro:

public class TileRule
{
    public enum RuleType
    {
        This,
        NotThis,
        Ignore
    }

    [TableMatrix(RowHeight = 20,SquareCells = true,DrawElementMethod = "DrawCell")]
    public RuleType[,] tilingRules = new RuleType[3,3];

    private static RuleType DrawCell(Rect rect, RuleType value)
    {
        if (Event.current.type == EventType.MouseDown &&
            rect.Contains(Event.current.mousePosition))
        {
            value = value == RuleType.Ignore ? RuleType.This : value+1;
            GUI.changed = true;
            Event.current.Use();
        }

        if(value == RuleType.This) EditorGUI.DrawRect(rect.Padding(1),new Color(0.6f,1f,0.3f));
        if(value == RuleType.NotThis) EditorGUI.DrawRect(rect.Padding(1),new Color(1f,0f,0.3f));
        if(value == RuleType.Ignore) EditorGUI.DrawRect(rect.Padding(1),new Color(0.6f,0.6f,0.6f));

        return value;
    }
}

Comments (1)

  1. Log in to comment