Setup
First of all, TweenToggle needs LeanTween to work properly. Download it for free on the Asset Store.
Getting Started
There are 2 types of scripts within the library.
TweenToggle Scripts
These are your basic tweening components that changes different attributes (position, rotation, scale, UI alpha, and CanvasGroup alpha). Each script exposes a ‘Show’ and ‘Hide’ method that is called externally.
Code Usage
using UnityEngine; using System.Collections; public class TweenToggleExample : MonoBehaviour { public TweenToggle positionTweenToggle; public void ShowObject() { positionTweenToggle.Show(); } public void HideObject() { positionTweenToggle.Hide(); } }
Editor Attributes
All TweenToggle scripts share these generic options
Is Using Demux – Automatically populated by any demuxes it is connected to, this box is here just for your sanity so you know if it is within a group or not. Do not touch this box.
Starts Hidden – Check if your UI needs to be hidden on start, used for hiding UI that show up later in your game.
Use Estimated Time – Tween independent of timescale. Useful for pause menus that zeroes time scale.
Show Delay – Delay in seconds before tweeting starts when Show() is called.
Show Duration – Duration of the show tween.
Show Ease – Easing function of the show tween.
Hide Delay – Delay in seconds before tweeting starts when Hide() is called.
Hide Duration – Duration of the hide tween.
Hide Ease – Easing function of the hide tween.
On Show Complete – UnityAction(s) to call when show completes, works the same way as a Unity Button.
On Hide Complete – UnityAction(s) to call when hide completes, works the same way as a Unity Button.
TweenToggleDemux Script
TweenToggleDemux controls a group of TweenToggle scripts. This is how complex UI animations can be built. The demux initializes all the individual TweenToggles and calls all of them to either show or hide when it’s own Show() and Hide() methods are called.
It controls each TweenToggle’s IsUsingDemux variable and overrides the IsStartHidden variable.