Table of Contents

Motions

Motions are at the core of this library and the way they were thought was to be able to add as many as possible and customise them in any way you want. Here are some examples on of how to do that

Create

In the first file, there is an example of a motion that is built for an AnimationObject

Note: Only OnUpdate is mandatory for overriding. Other events available(virtual) are OnStart, OnLoopComplete, OnComplete

public class CustomMotion : AbstractTweenMotion
{
    public CustomMotion(AnimationObject item, float value) : base(item)
    {
        this.value = value;
    }
 
    private readonly float value;
    private float from;
    private float to;
 
    public override void OnStart()
    {
        from = item.Value;
        to = from + value;
    }
 
    public override void OnUpdate(float t)
    {
        item.Value = Mathf.LerpUnclamped(from, to, t);
    }
}

Extensions

An example of creating custom extensions to make things easier
public static TweenMotionProxy Custom(this TweenMotionProxy proxy, float value)
    => proxy.Apply(new CustomMotion(motion.Item, value));

Apply

  1. Appling the motion to an AnimationObject animationObject using the extension method
  2. Appling the motion directly to the tween
Tween tweenWithExtension = new Tween(1f).For(animationObject).Custom(1f);
Tween tweenWithApply = new Tween(1f).Apply(new CustomMotion(animationObject, 1f));