Switch Element

This asset brings the switch as a new UI element to Unity3D.
Inspired by the toggle element, it is as simple to use thanks to the editor integration.

6 examples of Switch styles are available as prefab.
Uses the Unity GUI, works with Unit3d 4.6 and up.
Switch Element Example

How To

The Switch element is added through the option menu. You need to select GameObject >> UI >> Switch.

You can also drag-and-drop one of the prefabs into the current scene (as a child of a GameObject containing a Canvas element).

Programmatically, the IsOn variable is what's most important. Set this boolean property to change the current state of the Switch.

Unity Editor

Within the Unity Editor you can tweak the following elements:

Selectable: you may have recognised the first options, they are found in all UI element ineheriting from Selectable. this is where you can customize all values related to interactibility.
Is On: the property used to toggle On and Off the switch element.
Text Color: the first element in the list is the color a selected label will use, the second is the color of the unselected one.
Panel Color: the first color is the one of the "selected" panel when the Switch's value is On, the second one when the Switch's value is Off.
Transition Duration: the duration of the tweening animation, start to complete.
Toggle Transition: the tweening equation to use. The equations can be found here.
Graphic: the "selected" element. This is a panel element that will be moved to show the current value of the Switch.
On Value Changed: use this to choose the method(s) invoked when the Switch's value changes.
Editor Example


Six different examples of Switch styles come with the asset.
Styles Example
Like any other UI native elements you can also modify it and implement your own design.