Game Development Reference
In-Depth Information
Classified intel
In this step, we were using GUI.SelectionGrid to create a list of the items. By using
GUI.SelectionGrid , we were able to create a list of buttons using one line of code
that have a fixed height and space, which was very convenient. We can see more details on
how to use GUI.SelectionGrid at the following URL:
http://unity3d.com/support/documentation/ScriptReference/GUI.SelectionGrid.html
GUI.tooltip
We also used the GUI.tooltip parameter to show our items' information when the play-
er rolls over each item and showed the selected item's information if the player rolls out.
So, how does GUI.tooltip work? Basically, GUI.tooltip will return the string from
each button that contains a tooltip string when the player rolls over it. However, if the play-
er rolls out or that button doesn't have any tooltip stored in it, this parameter will automat-
ically return a blank string, similar to the following code that we used in the ItemWin-
dow() function in the Menu script's class.
A Unity JavaScript user can use the following code:
var tooltip : String = ( GUI.tooltip != "") ? GUI.tooltip :
info;
A C# user can use the following code:
string tooltip = ( GUI.tooltip != "") ? GUI.tooltip : info;
We basically tell GUI.tooltip that we will assign the rollover tooltip information to the
label when the player rolls over. And, if the player rolls out, we will show the selected
item's information for which the default is the first item, as we can see in the following
screenshot:
Search WWH ::




Custom Search