Class UIAnimator
Component used to create and manage custom animations.
Properties
UIAnimations
UIAnimations related to the GameObject.
Methods
Cancel(String)
Cancel a UIAnimation based on its label.
Parameters
label (String) | The label of the animation to cancel. |
Examples
Cancel a UIAnimation related to the UIAnimator.
using UnityEngine;
using Str8lines.Tweening.UI;
public class MyClass : MonoBehaviour
{
public GameObject target;
private void Start()
{
if(target.TryGetComponent(out UIAnimator animator)){
animator.Cancel("animation_001");
}
}
}
Complete(String, Bool)
Complete a UIAnimation based on its label.
Parameters
label (String) | The label of the animation to complete. |
callbackOnComplete (Bool) | (Optional) If |
Examples
Complete a UIAnimation related to the UIAnimator.
using UnityEngine;
using Str8lines.Tweening.UI;
public class MyClass : MonoBehaviour
{
public GameObject target;
private void Start()
{
if(target.TryGetComponent(out UIAnimator animator)){
animator.Complete("animation_001");
}
}
}
CreateAnimation()
Create a UIAnimation with a uuid, a default label and sets the current GameObject as its target.
Returns
UIAnimation
➜ The UIAnimation created.
Examples
Add a UIAnimation to the UIAnimator.
using UnityEngine;
using Str8lines.Tweening.UI;
public class MyClass : MonoBehaviour
{
public GameObject target;
private void Start()
{
if(target.TryGetComponent(out UIAnimator animator)){
UIAnimation animation = animator.CreateAnimation();
}
}
}
Delete(String)
Delete a UIAnimation based on its uuid except if it's the last animation.
Parameters
uuid (String) | The uuid of the animation to delete. |
Returns
Bool
➜ true
if UIAnimation is deleted.
Examples
Delete a UIAnimation related to the UIAnimator.
using UnityEngine;
using Str8lines.Tweening.UI;
public class MyClass : MonoBehaviour
{
public GameObject target;
private void Start()
{
if(target.TryGetComponent(out UIAnimator animator)){
animator.Delete("7aac6207-107f-4ddc-8761-122f669d3e3b");
}
}
}
GetAnimation(String)
Get a UIAnimation based on its uuid.
Parameters
uuid (String) | The uuid of the animation to fetch. |
Returns
UIAnimation
➜ The UIAnimation if found, else null
.
Examples
Get a UIAnimation created with the UIAnimator based on its uuid.
using UnityEngine;
using Str8lines.Tweening.UI;
public class MyClass : MonoBehaviour
{
public GameObject target;
private void Start()
{
if(target.TryGetComponent(out UIAnimator animator)){
UIAnimation animation = animator.GetAnimation("7aac6207-107f-4ddc-8761-122f669d3e3b");
}
}
}
GetAnimations(String)
Get UIAnimations having a given label.
Parameters
label (String) | The label of the animations to fetch. |
Returns
UIAnimation[]
➜ The array of UIAnimations found.
Examples
Get UIAnimations created with the UIAnimator based on their label.
using UnityEngine;
using Str8lines.Tweening.UI;
public class MyClass : MonoBehaviour
{
public GameObject target;
private void Start()
{
if(target.TryGetComponent(out UIAnimator animator)){
UIAnimation animation = animator.GetAnimations("animation_001");
}
}
}
Pause(String)
Pause a UIAnimation based on its label.
Parameters
label (String) | The label of the animation to pause. |
Examples
Pause a UIAnimation related to the UIAnimator.
using UnityEngine;
using Str8lines.Tweening.UI;
public class MyClass : MonoBehaviour
{
public GameObject target;
private void Start()
{
if(target.TryGetComponent(out UIAnimator animator)){
animator.Pause("animation_001");
}
}
}
Play(String)
Play a UIAnimation based on its label.
Parameters
label (String) | The label of the animation to play. |
Examples
Play a UIAnimation related to the UIAnimator.
using UnityEngine;
using Str8lines.Tweening.UI;
public class MyClass : MonoBehaviour
{
public GameObject target;
private void Start()
{
if(target.TryGetComponent(out UIAnimator animator)){
animator.Play("animation_001");
}
}
}
Resume(String)
Resume a UIAnimation based on its label.
Parameters
label (String) | The label of the animation to resume. |
Examples
Resume a UIAnimation related to the UIAnimator.
using UnityEngine;
using Str8lines.Tweening.UI;
public class MyClass : MonoBehaviour
{
public GameObject target;
private void Start()
{
if(target.TryGetComponent(out UIAnimator animator)){
animator.Resume("animation_001");
}
}
}
Stop(String)
Stop a UIAnimation based on its label.
Parameters
label (String) | The label of the animation to stop. |
Examples
Stop a UIAnimation related to the UIAnimator.
using UnityEngine;
using Str8lines.Tweening.UI;
public class MyClass : MonoBehaviour
{
public GameObject target;
private void Start()
{
if(target.TryGetComponent(out UIAnimator animator)){
animator.Stop("animation_001");
}
}
}
Undo(String)
Reset values of the target's RectTransform, CanvasRenderer, SpriteRenderer and/or Graphic.
Parameters
label (String) | The label of the animation to undo. |
Examples
Press space to reset target values
using UnityEngine;
using Str8lines.Tweening.UI;
public class MyClass : MonoBehaviour
{
public UIAnimator animator;
private void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
animator.Undo("animation_001");
}
}
}