protected void DrawIconSelectionGrid(GUIStyle[] icons, float maxIconWidth) { float sidePanelWidth = CalculateSidePanelWidth(); int xCount = Mathf.FloorToInt((position.width - sidePanelWidth - kScrollbarWidth) / (maxIconWidth + kSelectionGridPadding)); int selected = GUILayout.SelectionGrid(-1, icons.Select(style => style.normal.background).ToArray(), xCount, GUI.skin.box); if (selected > -1) { SetSelectedIcon(icons[selected]); } }