Overview
The State Toggle Button control type works much like a traditional checkbox/toggle button, except that it supports an arbitrary number of states. It will advance incrementally from one state to the next every time it is clicked/tapped, and upon reaching the last state, if clicked/tapped again, it will return to the first state and start over. To cause it to behave as a standard checkbox, simply assign it two states.
|
Interactivity
The State Toggle Button control type executes code in response to user input by invoking a method on a MonoBehavior (specified by setting the "Script With Method To Invoke" and "Method To Invoke" properties), and/or by calling a delegate, set by calling the SetInputDelegate() method through script. When then value of the control changes as a result of user input, any registered EZValueChangedDelegate delegate will be called. You can retrieve the current state of the control by accessing the StateNum and StateName properties which return the index of the current state and the name of the current state, respectively. You can set the current state of the control by calling SetToggleState() which accepts either the index of the desired state, or the case-sensitive name of the desired state. The state can be "manually" advanced through script by calling ToggleState(). |
Control-specific Properties
Default State - The index of the state to which the control should default. Sound To Play - The sound to be played when the button is tapped. Disable Hover Effect - When false, any "layer" that is set will be assumed to contain states for "Over" and "Active" so as to provide visuals for the "Hover" effect, as well as the "Active" (pressed) effect. When true, however, the layers are assumed to only be used to mirror the control's current state/value, and will not provide "Over" and "Active" state appearances. For more details, see here. |
States
Unlike other controls, the State Toggle Button does not have a fixed set of states. Instead, you tell it how many states it should have, and set their names, if desired. You then simply proceed to assign textures to each state to define the appearance of that state. When setting up layers for a State Toggle Button, be sure to match the overlay's state/animation name with the corresponding state name you have assigned the the State Toggle Button's states. While there is no "Over" state for this control, you can achieve a "hover" appearance when the pointer is over the control by using the technique described in the Advanced topic, Hover Effects for Radios and Toggles. |