Game Development Reference
In-Depth Information
}
}
For a C# user, the following code exists:
_selectedItem = GUI.SelectionGrid (view,
_selectedItem, itemsContent, 1,
GUI.skin.GetStyle("Selected Item"));
The preceding code should be replaced with the following code:
for (int j = 0; j < itemsContent.Length; j++) {
if (_selectedItem == j) {
GUI.Label(new Rect (0, j*40, 280,
40),itemsContent[j],GUI.skin.GetStyle("Disabled
Click"));
} else {
if (GUI.Button(new Rect (0, j*40, 280,
40),itemsContent[j],GUI.skin.GetStyle("Selected
Item"))) {
_selectedItem = j;
}
}
}
In this function, first, we check the equipments or items to get the Rect position
of the item box. Then, we add the itemCount item if it's the equipment, which
is standing for the UNEQUIP selection. Next, we get the height of the scroll view
by calculating the number of items from the itemCount item. Then, we create
the scroll view by using GUI.BeginScrollView . Next, we create a
GUIContent array to contain our items and check if it's the equipment that we
add as the first item to UNEQUIP then add the rest. Next, we create
GUI.SelectionGrid and apply the selected item to _guiContent , which
will be used in the next step in the Menu script.
Search WWH ::




Custom Search