I don't know if this is possible but I am using two selection grids in my script. They work perfectly except for one thing. The SelectionGrids always have the first item appear to be selected even when its not. Until I press the first item to select it (even while in its downstate) the value itself will not change.
My question is; is there any way to create a SelectionGrid and have no values in it appear as they have been pressed or selected until you actually press an item.
the answer of Eric is good
but the code i use is like this
int selection =-1;//to make sure nothing is selected at first
void OnGUI()
{
selection = GUI.SelectionGrid(new Rect(0,0,100,50),selection, new string[]{"Option 1","Option 2"},1);
}
//remember the other parameters as number of elements and elements per line can be changed, just used those values to make an example =P
I just found an alternative to selection grid,you can loop through normal buttons and place them in a grid.for me it’s an advantage because I need a smaller grid.
for (var b7:int = 0; b7 < 36; b7 ++) {
if (GUI.RepeatButton (Rect(b7*10% 60+240,Mathf.Floor(-b7*10/60)*10+60,10,10),GUIContent("st","spherical area to apply modifier")))
{
Wt=(b7%6)+1; Ht=(Mathf.Floor(b7/6))+1;
}//+++++++++++++++++++++++++++++++++++++++++
GUI.Label (Rect(300,300,300,100),GUI.tooltip); }