Game Development Reference
In-Depth Information
Objective complete - mini debriefing
We just finished the last tab of our menu window. In this step, we created the
EQUIPMENT button that will bring up the selection window from which the player can
choose the type of equipment or skill. It will update the current equipment's status on the
STATUS tab too.
If we take a look at our EquipWindow() function, we will see that we call the
SetupScrollBar() function in the ItemsContainer class similar to what we did
in the ItemWindow() function, but this time it is the equipment. We know it is the
equipped object because we call the Init() function and pass the value isEquipment
to the Start() function of the Menu script.
For a Unity JavaScript User, the following code can be used:
function Init ( isEquipment : boolean ) : void {
_isEquipment = isEquipment;
}
For a C# User, the following code can be used:
void Init ( bool isEquipment ) : void {
_isEquipment = isEquipment;
}
Then, in the SetupScrollBar() function in the ItemsContainer class, we just
check that value to return the information and show it on the scroll view correctly.
For a Unity JavaScript user, the following highlighted code can be used:
if (itemCount > 1) {
for (var i : int = 0; i < itemCount; i++) {
itemsContent[i] = (_isEquipment) ? ((i == 0) ? new
GUIContent(UNEQUIP) : items[i-1].guiContent) :
items[i].guiContent;
}
} else {
Search WWH ::




Custom Search