LitMotion 1.5.0 has been released. This release includes several feature additions.
OnCancel
First, I added OnCancel callback. You can add a callback when canceling using WithOnCancel()
.
LMotion.Create(0, 10, 2)
.WithOnCancel(() => ...)
.BindToUnityLogger();
Bind with multiple states
Also, BindWithState()
now supports multiple states (up to 3). You can avoid closures and reduce allocation by passing objects as arguments.
LMotion.Create(0f, 1f, 2f)
.BindWithState(state1, state2, state3, (x, state1, state2, state3) => {
...
});
Animating text numbers
Additionally, it is now possible to bind motions with numeric values to Text! This makes it easier to perform processes like DOTween’s DOCounter()
, and when the target is TMP_Text
, it is written directly to the char[ ]
buffer, allowing animation with zero allocation!
TMP_Text text;
LMotion.Create(0, 100, 2f)
.BindToText(text);
If you want to set formats such as comma separation and number of digits, you can do so by passing a format string.
TMP_Text text;
LMotion.Create(0f, 100000f, 2f)
.BindToText(text, "{0:N2}");

Unfortunately, this feature uses string.Format()
and therefore incurs GC allocation. To get around this, LitMotion added support for ZString. Introducing ZString into your project automatically replaces these processes and achieves complete zero allocation.
Release note: