Game Development Reference
In-Depth Information
Turn off the Animation recording and play your scene. The Button when hovered over,
will now resize as well as change color as shown in the first screenshot in this section.
Feel free to play with other animation clips for the other states; go wild and see what
you can do. In the downloadable example that comes with this topic, I made the
button also rotate when clicked.
As noted, the complete sample is in the Code Download accompanying
this title if you get stuck.
Which direction to travel?
There are times in life when you reach a fork in the road and need to decide which
way to turn; here's where the Toggle control comes in, making a binary decision
much more fun and snazzy (ok, maybe not).
There's not much one can actually say about a
Toggle
control, it's on or it's off, job
done. Well almost.
The
Toggle
, like the
Button
control, is built from several other controls and
components, as shown here when it's added to the
Scene
:
As you can see the
Toggle
is a slightly more complex setup, comprising
several parts:
• The parent
Toggle
GameObject
• A child
Background
image for the
Toggle
box (a Unity base image)