Game Development Reference
In-Depth Information
//We create a GUIContent array of key item here (if you have
more than 1 items, you can also use your item array instead of the
current item)
for (var i: int = 0; i < in_items; i++) {
if (a_items.Length > 0) {
if (i == 0) {
itemsContent[i] = GUIContent(currentItem.itemNA,
currentItem.icon, "Lorem ipsum dolor sit amet, consectetur
adipisicing elit, sed do eiusmod tempor incididunt ut labore
et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat.");
} else {
itemsContent[i] = GUIContent(currentItem.itemNA,
currentItem.icon, "This is key " + i);
}
} else {
itemsContent[i] = GUIContent("NONE", "");
}
}
//We create the grid button here.
in_toolItems = GUI.SelectionGrid (Rect (0, 0, 280, 40*in_
items), in_toolItems, itemsContent, 1, GUI.skin.GetStyle("Selected
Item"));
GUI.EndScrollView (); //End Scroll Area
//Checking if there is an item information
var s_info : String = itemsContent[in_toolItems].tooltip;
if (s_info == "") {
s_info = "Show items information here";
}
var style : GUIStyle = GUI.skin.GetStyle("Label");
if (GUI.tooltip != "") {
//Get height from this style
var f_height : float = style.CalcHeight(GUIContent(GUI.
tooltip), 330.0);
scrollPosition2 = GUI.BeginScrollView (new Rect (257, 343,
320, 75), scrollPosition2, new Rect (0, 0, 280, f_height));
GUI.Label(new Rect (0, 0, 280, f_height), GUI.tooltip);
} else {
//Get height from this style
f_height = style.CalcHeight(GUIContent(s_info), 330.0);
scrollPosition2 = GUI.BeginScrollView (new Rect (257, 343,
320, 75), scrollPosition2, new Rect (0, 0, 280, f_height));
GUI.Label(new Rect (0, 0, 280, f_height), s_info);
} GUI.EndScrollView ();
}
 
Search WWH ::




Custom Search