Game Development Reference
In-Depth Information
Objective complete - mini debriefing
We just created our
INVENTORY
page that we'll be able to view by clicking on the
INVENTORY
tab. First, we created the item array by using
List<T>
to contain all the
items. Then we added the
SetupScrollBar()
function in the
ItemsContain-
er
class in this function, we created a scroll view for the items by using
GUI.BeginScrollView()
and
GUI.EndScrollView()
, and created a scrollable
area that contains all the items. We also used
GUI.SelectionGrid
to align all items in
the list from which the player can select any item. Lastly, we passed the
GUIContent
se-
lection to use in the
Menu
script.
Then, in the
Menu
script in the
Start()
function, we initialized our items, armors, ac-
cessories, weapons, and skills objects. Next, we created the
ItemWindow()
function,
which we used to control our item page. In this function, we created a scroll view. Then,
we got the current tooltip from
GUIContent
that we get from
ItemsContainer
and
checked whether there is any information or not. Next, we checked
GUI.tooltip
for
any stored string; if nothing is stored here, we assigned the current tooltip from our selected
items to
GUI.tooltip
, which showed the result that if we roll over each item, the cur-
rent information will change to the roll-overed item. On the other hand, if we roll over from
our items list, the result will show the selected item's information. Next, we get the
Label
style height from the current
GUI.tooltip
item. Then, we created another scroll view to
show this tooltip information in the box area.
In the
DoMyWindow()
function, we added the
INVENTORY
state to show the item page
when the user clicks on the
INVENTORY
tab by calling the
ItemWindow()
function.
At last, we created the
GameObject
prefab that has the
item
script attached to it and ad-
ded it to our item page.