Game Development Reference
In-Depth Information
Bring on the GUI
Before we can start acting on the state machine, we first need to add something for the
player to interact with, namely, the weapons the player possesses to knock those pesky
goblins into the middle of the next week.
To do this, we will add a nice 2D graphical command bar with button placements using
the 2D system instead of the aging Unity GUI system. The following is a sample of what
we will be building:
The system is also flexible and dynamic enough to work in any portion of the screen, with
any number of buttons, even with multiple columns and rows if you wish.
CommandBar (the container) manages the placement, and the state of the bar can contain
any number of command buttons; each button will display the item it is managing and its
input control.
As the command bar and command buttons are codependent, our code won't compile until
they are both implemented, so let's start with the CommandBar class and then add the
button definition to it.
Note
The command bar and button code was refactored and updated to 2D from an existing
open source project; it can be found at github.com/fholm/unityassets/tree/master/Ac-
tionBars .
The full 3D implementation also has several other features you might like to implement in
the command bar, such as cooldowns, multiselects, and descriptors. So check it out if you
wish.
Search WWH ::




Custom Search