Str8lines
Search Results for

    Show / Hide Table of Contents

    UIAnimator

    The animator is the component you work with to create and manage your animations.

    Inspector

    The animator interface is visible in the Unity inspector and is divided into several zones.

    Inspector's Interface

    Header

    Header area

    The header lists the animations you have created for the current GameObject.
    The "+" button will add an animation based on your presets.

    General

    General area

    The "general" area displays the UUID and allows you to rename the animation.
    You can also choose to play the animation automatically at the start of the game.
    The "initial values" are saved each time before an animation is played.
    However, if you tick the "lock initial values" box, the animator will only save the "initial values" once.

    Effects

    Effects area Move effect selected

    This area contains the effects you can select for a given animation.
    When they are selected their parameters are also displayed.

    Events

    Events area

    The last area is dedicated to events.
    These are UnityEvents that trigger functions or property changes at specific times :
    At the start of the animation (after the delay), after a loop or at the end.

    Thanks to them, you can link animations together quite easily.
    Use the "OnAnimationEnd" event in the Unity inspector and call the Play() method of the next animation you want to play.
    Repeat the operation as many times as you like.

    Add a listener Select a function Setting parameters

    The only thing to bear in mind is that you will have limited control over the animation sequence.
    In fact you need to identify the animation being played to be able to stop the sequence.
    Don't hesitate to separate complex animation sequences into subsequences.

    Beware, however, that the intensive use of events leads to certain difficulties.
    The most obvious is the order of execution of functions when you have a number of them.
    To solve this problem, it's best to call as few functions as possible.
    To reduce the number of function calls, it's best to dedicate events to specific uses, such as audio management.

    Properties

    The only property is an array of all the animations created using the CreateAnimation() function.

    Functions

    The animator has multiple functions that can be grouped into different categories.

    Create, Read, Delete

    The CreateAnimation() function creates an animation based on user's presets.
    You can retrieve animations in two different ways.
    By using their UUID you can retrieve a single animation with the GetAnimation() function.
    And by using a label, GetAnimations() will return an array of animations with that label.
    Finally, the Delete() function requires a UUID to delete an animation.

    Control

    All the other functions, with the exception of the Undo() method are used to control the animation lifecycle.
    The Undo() method resets the values of the target GameObject that have been tweened to their "initial values".
    All these functions use the GetAnimations() method and operate on the first entry in the returned array.
    They have the same name as the function that the animation calls.

    Additional resources

    • UIAnimator scripting api class reference
    • UIAnimation scripting api class reference
    • UIAnimation get started guide reference
    • GameObject external resource
    • Unity Components external resource
    • UnityEvent external resource
    In This Article

    Geoffrey Lesne (Str8lines) © 2024 - All rights reserved

    • facebook logo
    • linkedin logo
    • discord logo
    contact us / Back to top