Skip to content

Commit 88fcf42

Browse files
committed
fixed flexibleGridLayout spacing on Y troubles
1 parent 2be182e commit 88fcf42

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

UnityNativeToolkit/Assets/Scripts/Utils/FlexibleGridLayout.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ public override void CalculateLayoutInputHorizontal()
4949
float parentWidth = rectTransform.rect.width;
5050
float parentHeight = rectTransform.rect.height;
5151

52-
float cellWidth = (parentWidth / (float)columns) - ((spacing.x / (float)columns) * (columns - 1)) - (padding.left / (float)columns) - (padding.right / (float)columns);
53-
float cellHeight = parentHeight / (float)rows - ((spacing.y / (float)rows) * (columns - 1)) - (padding.top / (float)rows) - (padding.bottom / (float)rows);
52+
float cellWidth = (parentWidth / (float)columns) - (spacing.x / (float)columns * (columns - 1)) - (padding.left / (float)columns) - (padding.right / (float)columns);
53+
float cellHeight = (parentHeight / (float)rows) - (spacing.y / (float)rows * (rows - 1)) - (padding.top / (float)rows) - (padding.bottom / (float)rows);
5454

5555
cellSize.x = fitX ? cellWidth : cellSize.x;
5656
cellSize.y = fitY ? cellHeight : cellSize.y;
@@ -66,7 +66,7 @@ public override void CalculateLayoutInputHorizontal()
6666
var item = rectChildren[i];
6767

6868
var xPos = (cellSize.x * columnCount) + (spacing.x * columnCount) + padding.left;
69-
var yPos = (cellSize.y * rowCount) + (spacing.y * columnCount) + padding.top;
69+
var yPos = (cellSize.y * rowCount) + (spacing.y * rowCount) + padding.top;
7070

7171
SetChildAlongAxis(item, 0, xPos, cellSize.x);
7272
SetChildAlongAxis(item, 1, yPos, cellSize.y);

0 commit comments

Comments
 (0)