Take a loot at this code:
var buttonTexture : Texture2D;
var toolbarInt : int = 0;
var toolbarStrings : String[] = ["Item1", "Item2", "Item3"];
function OnGUI ()
{
GUI.contentColor = Color.yellow;
GUI.BeginGroup(Rect((Screen.width / 2 - 300), (Screen.height - 150), 600, 150));
GUI.Box(Rect(0, 15, 600, 150), "");
toolbarInt = GUI.Toolbar (Rect (10, 0, 250, 30), toolbarInt, toolbarStrings);
switch (toolbarInt)
{
case 0:
print("0");
GUI.contentColor = Color.white;
if (GUI.Button(Rect(10, 50, 80, 80), "button1"))
{
print("1.1");
}
if (GUI.Button(Rect(100, 50, 80, 80), "button2"))
{
print("1.2");
}
if (GUI.Button(Rect(190, 50, 80, 80), "button3"))
{
print("1.3");
}
if (GUI.Button(Rect(280, 50, 80, 80), "button4"))
{
print("1.4");
}
if (GUI.Button(Rect(370, 50, 80, 80), "button5"))
{
print("1.5");
}
break;
case 1:
print("1");
break;
case 2:
print("2");
break;
default:
break;
}
GUI.EndGroup();
}
The buttons inside toolbar wouldn’t work, why?