Game Development Reference
In-Depth Information
itemsContent[0] = (isNoItem) ? new GUIContent(NONE) :
((_ isEquipment) ? new GUIContent(UNEQUIP) :
items[0].guiContent);
}
For a C# user, the following highlighted code can be used:
if (itemCount > 1) {
for (int i = 0; i < itemCount; i++) {
itemsContent[i] = (_isEquipment) ? ((i == 0) ? new
GUIContent(UNEQUIP) : items[i-1].guiContent) :
items[i].guiContent;
}
} else {
itemsContent[0] = (isNoItem) ? new GUIContent(NONE) :
((_isEquipment) ? new GUIContent(UNEQUIP) :
items[0].guiContent);
}
Next, we call the SetupSkillScrollBar() function in the SkillsContainer
class, which has a very similar concept to the SetupScrollBar() function in the
ItemsContainer class, but this time it contains the texture instead of item informa-
tion, as shown in the following script:
itemsContent[i] = (i == 0) ? new
GUIContent(_skillBoxTexture) :new GUIContent(textures[i-1]);
In SetupSkillScrollBar() , we also set up the GUI.SelectionGrid parameter
to show the result in a horizontal view instead of a vertical view by passing the
itemCount item to the GUI.SelectionGrid() function, as we can see in the fol-
lowing code:
_selectedSkill = GUI.SelectionGrid (newView,
_selectedSkill, itemsContent, itemCount,
GUI.skin.GetStyle("Selected Item"));
At last, we create the equipment prefabs and add it to our Menu script to show all items
that the users can equip themselves when a weapon, armor, or accessory is selected.
Search WWH ::




Custom Search