Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ namespace LitMotion.Extensions
/// </summary>
public static class LitMotionTextMeshProExtensions
{
private static void StaticOnComplete(TextMeshProMotionAnimator animator, int charIndex) => animator.CompleteForChar(charIndex);

/// <summary>
/// Create a motion data and bind it to TMP_Text.fontSize
/// </summary>
Expand Down Expand Up @@ -587,10 +589,12 @@ public static MotionHandle BindToTMPCharColor<TOptions, TAdapter>(this MotionBui

var animator = TextMeshProMotionAnimator.Get(text);
animator.EnsureCapacity(charIndex + 1);
var handle = builder.WithOnComplete(animator.updateAction).Bind(animator, Box.Create(charIndex), static (x, animator, charIndex) =>

int index = charIndex;
var handle = builder.WithOnComplete(() => StaticOnComplete(animator, index)).Bind(animator, Box.Create(charIndex), static (x, animator, charIndex) =>
{
animator.charInfoArray[charIndex.Value].color = x;
animator.SetDirty();
animator.SetCharDirty(charIndex.Value);
});

return handle;
Expand All @@ -613,10 +617,12 @@ public static MotionHandle BindToTMPCharColorR<TOptions, TAdapter>(this MotionBu

var animator = TextMeshProMotionAnimator.Get(text);
animator.EnsureCapacity(charIndex + 1);
var handle = builder.WithOnComplete(animator.updateAction).Bind(animator, Box.Create(charIndex), static (x, animator, charIndex) =>

int index = charIndex;
var handle = builder.WithOnComplete(() => StaticOnComplete(animator, index)).Bind(animator, Box.Create(charIndex), static (x, animator, charIndex) =>
{
animator.charInfoArray[charIndex.Value].color.r = x;
animator.SetDirty();
animator.SetCharDirty(charIndex.Value);
});

return handle;
Expand All @@ -639,10 +645,12 @@ public static MotionHandle BindToTMPCharColorG<TOptions, TAdapter>(this MotionBu

var animator = TextMeshProMotionAnimator.Get(text);
animator.EnsureCapacity(charIndex + 1);
var handle = builder.WithOnComplete(animator.updateAction).Bind(animator, Box.Create(charIndex), static (x, animator, charIndex) =>

int index = charIndex;
var handle = builder.WithOnComplete(() => StaticOnComplete(animator, index)).Bind(animator, Box.Create(charIndex), static (x, animator, charIndex) =>
{
animator.charInfoArray[charIndex.Value].color.g = x;
animator.SetDirty();
animator.SetCharDirty(charIndex.Value);
});

return handle;
Expand All @@ -665,10 +673,12 @@ public static MotionHandle BindToTMPCharColorB<TOptions, TAdapter>(this MotionBu

var animator = TextMeshProMotionAnimator.Get(text);
animator.EnsureCapacity(charIndex + 1);
var handle = builder.WithOnComplete(animator.updateAction).Bind(animator, Box.Create(charIndex), static (x, animator, charIndex) =>

int index = charIndex;
var handle = builder.WithOnComplete(() => StaticOnComplete(animator, index)).Bind(animator, Box.Create(charIndex), static (x, animator, charIndex) =>
{
animator.charInfoArray[charIndex.Value].color.b = x;
animator.SetDirty();
animator.SetCharDirty(charIndex.Value);
});

return handle;
Expand All @@ -691,10 +701,12 @@ public static MotionHandle BindToTMPCharColorA<TOptions, TAdapter>(this MotionBu

var animator = TextMeshProMotionAnimator.Get(text);
animator.EnsureCapacity(charIndex + 1);
var handle = builder.WithOnComplete(animator.updateAction).Bind(animator, Box.Create(charIndex), static (x, animator, charIndex) =>

int index = charIndex;
var handle = builder.WithOnComplete(() => StaticOnComplete(animator, index)).Bind(animator, Box.Create(charIndex), static (x, animator, charIndex) =>
{
animator.charInfoArray[charIndex.Value].color.a = x;
animator.SetDirty();
animator.SetCharDirty(charIndex.Value);
});

return handle;
Expand All @@ -717,10 +729,12 @@ public static MotionHandle BindToTMPCharPosition<TOptions, TAdapter>(this Motion

var animator = TextMeshProMotionAnimator.Get(text);
animator.EnsureCapacity(charIndex + 1);
var handle = builder.WithOnComplete(animator.updateAction).Bind(animator, Box.Create(charIndex), static (x, animator, charIndex) =>

int index = charIndex;
var handle = builder.WithOnComplete(() => StaticOnComplete(animator, index)).Bind(animator, Box.Create(charIndex), static (x, animator, charIndex) =>
{
animator.charInfoArray[charIndex.Value].position = x;
animator.SetDirty();
animator.SetCharDirty(charIndex.Value);
});

return handle;
Expand All @@ -743,10 +757,12 @@ public static MotionHandle BindToTMPCharPositionX<TOptions, TAdapter>(this Motio

var animator = TextMeshProMotionAnimator.Get(text);
animator.EnsureCapacity(charIndex + 1);
var handle = builder.WithOnComplete(animator.updateAction).Bind(animator, Box.Create(charIndex), static (x, animator, charIndex) =>

int index = charIndex;
var handle = builder.WithOnComplete(() => StaticOnComplete(animator, index)).Bind(animator, Box.Create(charIndex), static (x, animator, charIndex) =>
{
animator.charInfoArray[charIndex.Value].position.x = x;
animator.SetDirty();
animator.SetCharDirty(charIndex.Value);
});

return handle;
Expand All @@ -769,10 +785,12 @@ public static MotionHandle BindToTMPCharPositionY<TOptions, TAdapter>(this Motio

var animator = TextMeshProMotionAnimator.Get(text);
animator.EnsureCapacity(charIndex + 1);
var handle = builder.WithOnComplete(animator.updateAction).Bind(animator, Box.Create(charIndex), static (x, animator, charIndex) =>

int index = charIndex;
var handle = builder.WithOnComplete(() => StaticOnComplete(animator, index)).Bind(animator, Box.Create(charIndex), static (x, animator, charIndex) =>
{
animator.charInfoArray[charIndex.Value].position.y = x;
animator.SetDirty();
animator.SetCharDirty(charIndex.Value);
});

return handle;
Expand All @@ -795,10 +813,12 @@ public static MotionHandle BindToTMPCharPositionZ<TOptions, TAdapter>(this Motio

var animator = TextMeshProMotionAnimator.Get(text);
animator.EnsureCapacity(charIndex + 1);
var handle = builder.WithOnComplete(animator.updateAction).Bind(animator, Box.Create(charIndex), static (x, animator, charIndex) =>

int index = charIndex;
var handle = builder.WithOnComplete(() => StaticOnComplete(animator, index)).Bind(animator, Box.Create(charIndex), static (x, animator, charIndex) =>
{
animator.charInfoArray[charIndex.Value].position.z = x;
animator.SetDirty();
animator.SetCharDirty(charIndex.Value);
});

return handle;
Expand All @@ -821,10 +841,12 @@ public static MotionHandle BindToTMPCharRotation<TOptions, TAdapter>(this Motion

var animator = TextMeshProMotionAnimator.Get(text);
animator.EnsureCapacity(charIndex + 1);
var handle = builder.WithOnComplete(animator.updateAction).Bind(animator, Box.Create(charIndex), static (x, animator, charIndex) =>

int index = charIndex;
var handle = builder.WithOnComplete(() => StaticOnComplete(animator, index)).Bind(animator, Box.Create(charIndex), static (x, animator, charIndex) =>
{
animator.charInfoArray[charIndex.Value].rotation = x;
animator.SetDirty();
animator.SetCharDirty(charIndex.Value);
});

return handle;
Expand All @@ -847,10 +869,12 @@ public static MotionHandle BindToTMPCharEulerAngles<TOptions, TAdapter>(this Mot

var animator = TextMeshProMotionAnimator.Get(text);
animator.EnsureCapacity(charIndex + 1);
var handle = builder.WithOnComplete(animator.updateAction).Bind(animator, Box.Create(charIndex), static (x, animator, charIndex) =>

int index = charIndex;
var handle = builder.WithOnComplete(() => StaticOnComplete(animator, index)).Bind(animator, Box.Create(charIndex), static (x, animator, charIndex) =>
{
animator.charInfoArray[charIndex.Value].rotation = Quaternion.Euler(x);
animator.SetDirty();
animator.SetCharDirty(charIndex.Value);
});

return handle;
Expand All @@ -873,12 +897,14 @@ public static MotionHandle BindToTMPCharEulerAnglesX<TOptions, TAdapter>(this Mo

var animator = TextMeshProMotionAnimator.Get(text);
animator.EnsureCapacity(charIndex + 1);
var handle = builder.WithOnComplete(animator.updateAction).Bind(animator, Box.Create(charIndex), static (x, animator, charIndex) =>

int index = charIndex;
var handle = builder.WithOnComplete(() => StaticOnComplete(animator, index)).Bind(animator, Box.Create(charIndex), static (x, animator, charIndex) =>
{
var eulerAngles = animator.charInfoArray[charIndex.Value].rotation.eulerAngles;
eulerAngles.x = x;
animator.charInfoArray[charIndex.Value].rotation = Quaternion.Euler(eulerAngles);
animator.SetDirty();
animator.SetCharDirty(charIndex.Value);
});

return handle;
Expand All @@ -901,12 +927,14 @@ public static MotionHandle BindToTMPCharEulerAnglesY<TOptions, TAdapter>(this Mo

var animator = TextMeshProMotionAnimator.Get(text);
animator.EnsureCapacity(charIndex + 1);
var handle = builder.WithOnComplete(animator.updateAction).Bind(animator, Box.Create(charIndex), static (x, animator, charIndex) =>

int index = charIndex;
var handle = builder.WithOnComplete(() => StaticOnComplete(animator, index)).Bind(animator, Box.Create(charIndex), static (x, animator, charIndex) =>
{
var eulerAngles = animator.charInfoArray[charIndex.Value].rotation.eulerAngles;
eulerAngles.y = x;
animator.charInfoArray[charIndex.Value].rotation = Quaternion.Euler(eulerAngles);
animator.SetDirty();
animator.SetCharDirty(charIndex.Value);
});

return handle;
Expand All @@ -929,12 +957,14 @@ public static MotionHandle BindToTMPCharEulerAnglesZ<TOptions, TAdapter>(this Mo

var animator = TextMeshProMotionAnimator.Get(text);
animator.EnsureCapacity(charIndex + 1);
var handle = builder.WithOnComplete(animator.updateAction).Bind(animator, Box.Create(charIndex), static (x, animator, charIndex) =>

int index = charIndex;
var handle = builder.WithOnComplete(() => StaticOnComplete(animator, index)).Bind(animator, Box.Create(charIndex), static (x, animator, charIndex) =>
{
var eulerAngles = animator.charInfoArray[charIndex.Value].rotation.eulerAngles;
eulerAngles.z = x;
animator.charInfoArray[charIndex.Value].rotation = Quaternion.Euler(eulerAngles);
animator.SetDirty();
animator.SetCharDirty(charIndex.Value);
});

return handle;
Expand All @@ -957,10 +987,12 @@ public static MotionHandle BindToTMPCharScale<TOptions, TAdapter>(this MotionBui

var animator = TextMeshProMotionAnimator.Get(text);
animator.EnsureCapacity(charIndex + 1);
var handle = builder.WithOnComplete(animator.updateAction).Bind(animator, Box.Create(charIndex), static (x, animator, charIndex) =>

int index = charIndex;
var handle = builder.WithOnComplete(() => StaticOnComplete(animator, index)).Bind(animator, Box.Create(charIndex), static (x, animator, charIndex) =>
{
animator.charInfoArray[charIndex.Value].scale = x;
animator.SetDirty();
animator.SetCharDirty(charIndex.Value);
});

return handle;
Expand All @@ -983,10 +1015,12 @@ public static MotionHandle BindToTMPCharScaleX<TOptions, TAdapter>(this MotionBu

var animator = TextMeshProMotionAnimator.Get(text);
animator.EnsureCapacity(charIndex + 1);
var handle = builder.WithOnComplete(animator.updateAction).Bind(animator, Box.Create(charIndex), static (x, animator, charIndex) =>

int index = charIndex;
var handle = builder.WithOnComplete(() => StaticOnComplete(animator, index)).Bind(animator, Box.Create(charIndex), static (x, animator, charIndex) =>
{
animator.charInfoArray[charIndex.Value].scale.x = x;
animator.SetDirty();
animator.SetCharDirty(charIndex.Value);
});

return handle;
Expand All @@ -1009,10 +1043,12 @@ public static MotionHandle BindToTMPCharScaleY<TOptions, TAdapter>(this MotionBu

var animator = TextMeshProMotionAnimator.Get(text);
animator.EnsureCapacity(charIndex + 1);
var handle = builder.WithOnComplete(animator.updateAction).Bind(animator, Box.Create(charIndex), static (x, animator, charIndex) =>

int index = charIndex;
var handle = builder.WithOnComplete(() => StaticOnComplete(animator, index)).Bind(animator, Box.Create(charIndex), static (x, animator, charIndex) =>
{
animator.charInfoArray[charIndex.Value].scale.y = x;
animator.SetDirty();
animator.SetCharDirty(charIndex.Value);
});

return handle;
Expand All @@ -1035,10 +1071,12 @@ public static MotionHandle BindToTMPCharScaleZ<TOptions, TAdapter>(this MotionBu

var animator = TextMeshProMotionAnimator.Get(text);
animator.EnsureCapacity(charIndex + 1);
var handle = builder.WithOnComplete(animator.updateAction).Bind(animator, Box.Create(charIndex), static (x, animator, charIndex) =>

int index = charIndex;
var handle = builder.WithOnComplete(() => StaticOnComplete(animator, index)).Bind(animator, Box.Create(charIndex), static (x, animator, charIndex) =>
{
animator.charInfoArray[charIndex.Value].scale.z = x;
animator.SetDirty();
animator.SetCharDirty(charIndex.Value);
});

return handle;
Expand Down
Loading