/// <summary> /// Set the number of columns for the grid, grid is embedded in a scroll view so rows is unlimeted. /// Elements will be forced to be square based on button width /// </summary> /// <param name="cols"></param> private void ConfigureGridSize(int cols) { _columns = cols; var gridRect = _gridLayout.RectTransform(); var buttonWidth = gridRect.rect.width / cols; _gridLayout.cellSize = new Vector2(buttonWidth, buttonWidth); }