Logo
Animation

UI Animator

An event driven animation system for UI elements

Overview

UI Animator is a flexible animation system for UI objects that supports multiple animation types, easing options, and trigger based playback. Each animation is organized into groups that respond to specific events such as On Enable, pointer events, click, or manual calls, allowing you to build layered interactions on a single component.


Usage

Add UI Animator component to a UI object

Optionally assign references if needed:

  • Rect Transform
  • Canvas Group
  • Image
  • Text

Create one or more Animation Groups

  • Set a Trigger
  • Add one or more Animations to the group

Adjust animation settings such as duration, easing, looping, and type specific values


Properties

NameTypeDescription
animationGroupsList<AnimationGroup>Collection of animation groups, each with its own trigger and animation list
rectTransformRectTransformTarget RectTransform used for position, rotation, scale, shake, and bounce animations
canvasGroupCanvasGroupCanvasGroup used for fade animations and alpha control
imageImageOptional Image used for color tinting
textTMP_TextOptional TextMesh Pro text used for color tinting if Image is not set
useUnscaledTimeboolUse unscaled time for all animations (ignores Time.timeScale)

Animation Data

Each Animation Group contains a list of Animation Data entries. Each entry controls one animation of a given type.

NameTypeDescription
typeAnimationTypeType of animation (Fade, Scale, Slide, Rotate, PunchScale, Shake, Bounce, ColorTint)
enabledboolIf disabled, this animation entry is ignored
durationfloatTime in seconds for the animation to complete
delayfloatTime in seconds to wait before starting this animation
easeTypeEaseTypeEasing function used for the animation progression
loopboolIf true, the animation repeats until interrupted
yoyoboolIf true, the animation plays forward then backward each loop cycle
animateFromCurrentValueboolIf true, the animation starts from the current value instead of the configured "from" value

Type Specific Fields

Depending on AnimationType, the following fields are used:

Animation TypeFieldsDescription
FadefadeFrom, fadeToStart and end alpha values for the CanvasGroup
ScalescaleFrom, scaleToStart and end local scale values
SlideslideFrom, slideToOffset from the original anchored position (from and to)
RotaterotateFrom, rotateToStart and end rotation angles (Z axis)
PunchScalepunchIntensityPunch strength applied around the current scale
ShakeshakeIntensityShake strength applied to the anchored position
BouncebounceHeightHeight of the bounce along the Y axis
ColorTintcolorFrom, colorToStart and end color used to tint Image or Text

PunchScale, Shake, and Bounce automatically restore the target to its original values when they finish if they are not looping.


Animation Types

AnimationType defines the behavior of each animation entry.

TypeDescription
FadeAnimates CanvasGroup alpha between two values
ScaleAnimates local scale between two Vector3 values
SlideAnimates anchored position relative to the original position
RotateAnimates rotation around the Z axis
PunchScaleApplies a pulsing punch effect around the current scale
ShakeApplies a decreasing shake effect to the position
BounceMoves the element up and down in a bounce motion
ColorTintAnimates Image or Text color between two colors

Triggers

Each Animation Group uses a TriggerType. When the trigger occurs, all enabled animations in that group are played.

TriggerDescription
OnEnablePlays when the GameObject is enabled
OnClickPlays on pointer click (IPointerClickHandler)
OnPointerEnterPlays when the pointer enters the element
OnPointerLeavePlays when the pointer leaves the element
OnPointerDownPlays when the pointer is pressed down over the element
OnPointerUpPlays when the pointer is released over the element
ManualOnly plays when triggered via code with PlayManualAnimations()

Public Methods

NameParametersDescription
ExecuteAnimations(triggerType)TriggerType triggerTypePlays all enabled animation groups that match the given trigger
StopAllAnimations()NoneStops all running animations and clears active animation state
PlayManualAnimations()NonePlays all animation groups that use the Manual trigger
ResetToOriginalValues()NoneStops all animations and restores original position, scale, rotation, alpha, and color
RemoveAnimationGroup(index)int indexRemoves the animation group at the given index

Code Example

UIAnimatorExample.cs
using UnityEngine;
using Evo.UI;

public class UIAnimatorExample : MonoBehaviour
{
    public UIAnimator uiAnimator;

    void Start()
    {
        // Play manual animations
        uiAnimator.PlayManualAnimations();
    }

    public void OnButtonHover()
    {
        // Execute all Pointer Enter groups from code
        uiAnimator.ExecuteAnimations(UIAnimator.TriggerType.OnPointerEnter);
    }

    public void OnButtonClick()
    {
        // Execute all Click groups from code
        uiAnimator.ExecuteAnimations(UIAnimator.TriggerType.OnClick);
    }

    public void ResetUI()
    {
        // Restore original values if needed
        uiAnimator.ResetToOriginalValues();
    }
}

On this page