diff --git a/Scripts/Layout/TableLayoutGroup.cs b/Scripts/Layout/TableLayoutGroup.cs index 160b52a..0d68bd3 100644 --- a/Scripts/Layout/TableLayoutGroup.cs +++ b/Scripts/Layout/TableLayoutGroup.cs @@ -31,7 +31,7 @@ namespace UnityEngine.UI.Extensions } [SerializeField] - protected float[] columnWidths = new float[0]; + protected float[] columnWidths = new float[1] { 96f }; /// /// The widths of all the columns in the table /// @@ -122,6 +122,9 @@ namespace UnityEngine.UI.Extensions public override void CalculateLayoutInputVertical() { + if (columnWidths.Length == 0) + return; + int rowCount = Mathf.CeilToInt(rectChildren.Count / (float)columnWidths.Length); maxPreferredHeightInRows = new float[rowCount]; @@ -182,6 +185,9 @@ namespace UnityEngine.UI.Extensions { int columnCount = columnWidths.Length; + if (columnCount == 0) + return; + for (int i = 0; i < rectChildren.Count; i++) { RectTransform child = rectChildren[i]; @@ -199,11 +205,14 @@ namespace UnityEngine.UI.Extensions public override void SetLayoutVertical() { - float tableLayoutHeight = rectTransform.rect.height; - int columnCount = columnWidths.Length; + if (columnCount == 0) + return; + int rowCount = Mathf.CeilToInt(rectChildren.Count / (float)columnCount); + float tableLayoutHeight = rectTransform.rect.height; + int cornerX = (int)startCorner % 2; int cornerY = (int)startCorner / 2;