I'm trying to make a Level Select screen for my game using GUI.SelectionGrid but I'm having a couple problems:
I applied a GUIStyle to my SelectionGrid which includes a "hover" style. This works fine EXCEPT on the very first element of the grid, which doesn't change color when hovered over (this is the same with "active" as well as "hover")
It seems that when I click, even if I don't click on one of the grid buttons, it registers the nearest one as active, so I could click in the very far corner but it will think I'm clicking on one of the buttons
Code:
using UnityEngine;
using System.Collections;
public class LevelSelect : MonoBehaviour {
private int levelCount;
private int selected = -1;
private string[] grid;
public GUIStyle style;
void Start()
{
levelCount = Application.levelCount-2;
grid = new string[levelCount];
for(int i = 0; i < levelCount; i++)
{
grid *= "Level " + i;*
*}*
*}*
*void OnGUI() {*
*selected = GUI.SelectionGrid(new Rect(0,0, Screen.width, Screen.height), 0, grid, 5, style);*
*if(Input.GetMouseButtonUp(0))*
*{*
*Application.LoadLevel(selected+2);*
*}*
*}*
*}*
*```*