Game Development Reference
In-Depth Information
items.SetupScrollBar();
string info = (items.guiContent.tooltip == "") ?
"Show items information here" :
items.guiContent.tooltip;
GUIStyle style = GUI.skin.GetStyle("Label");
string tooltip = ( GUI.tooltip != "") ? GUI.tooltip
: info;
float height = style.CalcHeight(new
GUIContent(tooltip), 330.0f) + 20;
_scrollPosition = GUI.BeginScrollView (new Rect
(257, 343, 320, 75), _scrollPosition, new Rect (0, 0,
280, height));
GUI.Label(new Rect (0, 0, 280, height), tooltip);
GUI.EndScrollView ();
}
In this function, we first set up the item box and the item tooltip box. Then, we
create the item scroll view by calling
items.SetupScrollBar()
. Lastly, we
get the selected item tooltip, check if the tooltip isn't an empty string if it's as-
signed to our string. Then, we calculate the height of this tooltip box by using the
Label
style and create the scroll view for it.
6. Then, we go to the
DoMyWindow()
function inside the
switch
statement and
add the highlighted code inside this function to show the
INVENTORY
window
when we click on the
INVENTORY
tab, as follows:
// Unity JavaScript user:
private function DoMyWindow (windowID : int) : void {
…
switch (_currentTool) {
case TAB.STATUS : //Status
…
break;
case TAB.INVENTORY : //Items
ItemWindow();
break;
}
…
}