Game Development Reference
In-Depth Information
Objective Complete - Mini Debriefing
We just added an
Item
class to contain our item's informaion, which will be shown on
the equipment box, and will use this in the next step. Then, we created a
GUIContent
to
contain the image, name, and informaion of our items in the
Start()
funcion, and set it
to an
UNEQUIP
stage. Next, we added and created the
StatusWindow()
funcion to show
the status page when the player sees our menu at irst click on the status tab buton. We also
created a
CheckMax()
funcion to make sure that the number of the character atributes is
not over the limit.
Classified Intel
In this secion, we used
GUIContent
to contain the informaion of our items and pass
to
GUI.Label()
funcion. Basically, if we take a look at each
GUI
class funcion, we will
see that it can take many variables such as
Rect
,
string
,
Texture
,
GUIContent
, and
GUIStyle
. We already know what
Rect
,
string
, and
Texture
are.
GUIStyle
is the name
of the style from our
MenuSkin
object that we created, but what is
GUIContent
? It is
basically a class that contains the necessary variables to apply to our
GUI
. For example, if we
want our buton to have an icon, name, and informaion when the user rolls over it, we can
add this code:
GUI.Button(Rect(0,0,100,20), GUIContent("My Button Name",
icon, "This is the button info")
. The first parameter is the
string
that will be
shown inside the buton, and next is the graphic
Texture
that will also be shown inside
this buton. The last
string
is the informaion that will be stored in this buton, which we
call
tooltip
. We can show this
tooltip
when the user rolls over this buton by calling
GUI.
tooltip
. It will automaically show the current buton
tooltip
that the user rolls over. We
will use it in the next secion.
For more details about
GUIContent
and
GUI.tooltip
, we can
check out
this website:
ScriptReference/GUIContent.GU
IContent.html
.
Creating an inventory tab
So, we are in the second page of our menu window, which is the inventory page. In this
secion, we will create an item scroll that the player can use to scroll up and down to select
the item and see its name, amount, and informaion of the item.