Game Development Reference
In-Depth Information
9. In the last funcion, we will create the ShowSkill() funcion, which will be used to
display the skills box as follows:
private function ShowSkill () : void {
var in_items : int = a_skills.length + 1;
var itemsContent : GUIContent[] = new GUIContent[in_items];
//We create a GUIContent array of key item here (if you have
more than 1 item, you can also use your item array instead of the
current item)
for (var i: int = 0; i < in_items; i++) {
if (i == 0) {
itemsContent[i] = GUIContent(t_skillBox);
} else {
itemsContent[i] = GUIContent(a_skills[i-1]);
}
}
scrollPosition3 = GUI.BeginScrollView (new Rect (253, 286, 330,
140), scrollPosition3, new Rect (0, 0, 600, 117));
//We create grid button here.
in_toolskill = GUI.SelectionGrid (Rect (0, 4, 600, 117), in_
toolskill, itemsContent, in_items, GUI.skin.GetStyle("Selected
Item"));
// End the scrollview we began above.
GUI.EndScrollView ();
if(in_toolskill != 0) {
gui_skillCon = itemsContent[in_toolskill];
} else {
gui_skillCon = GUIContent("");
}
}
10. Now, we go back to Unity and click on the Menu object in the Hierarchy to bring up
its Inspector . Then, we set up the following properies:
F A_weapons
Size : 1
Element 0
Icon : Drag-and-drop weapon.png from Chapter2/
images here
Name : Dark Fist
Amount : 1
 
Search WWH ::




Custom Search