Composite controls are extremely used, Toolbar,selectgrid
Look first:
Toolbar can be seen as a collection of button buttons, one button at a time,
Selectgrid can also be called a collection of toolbar.
The code is as follows:
Using unityengine;using System.collections;public class Gui2:monobehaviour {int toolbarint=0;//represents the default N-1 button is an active string [] toolbarstring={"Tools", "Forms", "help"};//the number of button names and sets int selectgrid=0;string[] selectgridsring = {"Grid 1", "Grid 2", "Grid 3", " Grid 4 "," Grid 5 "};//use Initializationvoid Start () {}//update was called once per framevoid update () {}void on Gui () {toolbarint = GUI. Toolbar (New Rect (0, 0, up, max), Toolbarint, toolbarstring); Selectgrid = GUI. Selectiongrid (New Rect, Selectgrid, selectgridsring, 2),//2 columns, unity can automatically scale//detect if the control has changed if (gui.changed {print ("Some controls have changed");//The specific control click Change if (toolbarint==1) {print ("toolbar1 was clicked");}}}}
Comments are also more complete, the specific do not understand the time can be self-check API.
Learn Unity3d from scratch (GUI Chapter 2)