πŸ–ΌοΈCustomToggle

used to toggle two sprites or UI images.

What for

There is two implementations of CustomToggle -> SpriteToggle and ImageToggle. SpriteToggle is used to toggle between two sprites ImageToggle is used to toggle between two images Any CustomToggle requires Button component (you can use VibroBtn as Button too).

How to use

For ImageToggle -> add it to object with Image component. If there was no Button -> Button component will be added. If you want to use VibroBtn -> remove ImageToggle and Button components and add VibroBtn and then ImageToggle. References will be setuped automaticaly, but you can change it too.

How setup looks in the inspector

Now set default IsOn value and On/Off sprites. If you need to use null Off Sprite -> use prefab ToggleWithEmptySprite (unprefab to not override template)

API

/// <summary>
/// arg1 - changed isOn bool value
/// </summary>
public UnityEvent<bool> OnStateChanged = new UnityEvent<bool>();

/// <summary>
/// You can change toggle state IsOn = true/false
/// </summary>
public bool IsOn;

/// <summary>
/// Sets opposite state
/// </summary>
public void Toggle();

Last updated