Game Development Reference
In-Depth Information
The
Toggle Group
script does
not
check or manage the initial state of the
Toggles it manages, only the selection logic is handled. So if all Toggles
are
on/checked
by default, then
all
will be on when the scene starts. Only
after all but one have been unselected by the user will the script control
the selection.
If you want one set as the default, then just be sure that only that one is
checked by default.
6.
Duplicate the
Toggle
GameObject a couple of times and reposition them in
the scene.
If you run the scene, you will see that by default all the
Toggles
are unchecked, by
clicking one
Toggle
it will be selected. If you then select another
Toggle
, then the
previous
Toggle
that was selected is now unchecked as only one can be checked
at a time.
You don't have to arrange the GameObjects this way, they can be anywhere in the
scene. Just be sure to have your
Toggles
in the scene that you want grouped together
and set the same
Toggle Group
GameObject as the
Group
property of each
Toggle
.
Dynamic event properties
In the
Button
control, you had an event that was a single action—click on this and do
this; there was no additional information fed from the action to say anything about it.
With the
Toggle
however, it has a
Boolean
state, which means we have a potential
input to use or pass to whatever action we wish to perform. These are referred to as
dynamic parameters
and are exposed as separate options when we try to select an
action on a
GameObject
, as shown here:
The Event handler with a Toggle selected showing Dynamic (top) values and Fixed/Static (bottom) parameters