Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: the behavior of TextMeshPro character motions was unstable. #75

Merged
merged 4 commits into from
Jan 27, 2024
Merged
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 @@ -507,10 +507,16 @@ public static MotionHandle BindToTMPCharColor<TOptions, TAdapter>(this MotionBui
where TAdapter : unmanaged, IMotionAdapter<Color, TOptions>
{
Error.IsNull(text);
return builder.BindWithState(text, (x, target) =>

var animator = TextMeshProMotionAnimator.Get(text);
animator.EnsureCapacity(charIndex + 1);
var handle = builder.BindWithState(animator, (x, target) =>
{
TextMeshProHelper.SetCharColor(target, charIndex, x);
animator.charInfoArray[charIndex].color = x;
});
animator.motionHandleList.Add(handle);

return handle;
}

/// <summary>
Expand All @@ -527,10 +533,16 @@ public static MotionHandle BindToTMPCharColorR<TOptions, TAdapter>(this MotionBu
where TAdapter : unmanaged, IMotionAdapter<float, TOptions>
{
Error.IsNull(text);
return builder.BindWithState(text, (x, target) =>

var animator = TextMeshProMotionAnimator.Get(text);
animator.EnsureCapacity(charIndex + 1);
var handle = builder.BindWithState(animator, (x, target) =>
{
TextMeshProHelper.SetCharColorR(target, charIndex, x);
animator.charInfoArray[charIndex].color.r = x;
});
animator.motionHandleList.Add(handle);

return handle;
}

/// <summary>
Expand All @@ -547,10 +559,16 @@ public static MotionHandle BindToTMPCharColorG<TOptions, TAdapter>(this MotionBu
where TAdapter : unmanaged, IMotionAdapter<float, TOptions>
{
Error.IsNull(text);
return builder.BindWithState(text, (x, target) =>

var animator = TextMeshProMotionAnimator.Get(text);
animator.EnsureCapacity(charIndex + 1);
var handle = builder.BindWithState(animator, (x, target) =>
{
TextMeshProHelper.SetCharColorG(target, charIndex, x);
animator.charInfoArray[charIndex].color.g = x;
});
animator.motionHandleList.Add(handle);

return handle;
}

/// <summary>
Expand All @@ -567,10 +585,16 @@ public static MotionHandle BindToTMPCharColorB<TOptions, TAdapter>(this MotionBu
where TAdapter : unmanaged, IMotionAdapter<float, TOptions>
{
Error.IsNull(text);
return builder.BindWithState(text, (x, target) =>

var animator = TextMeshProMotionAnimator.Get(text);
animator.EnsureCapacity(charIndex + 1);
var handle = builder.BindWithState(animator, (x, target) =>
{
TextMeshProHelper.SetCharColorB(target, charIndex, x);
animator.charInfoArray[charIndex].color.b = x;
});
animator.motionHandleList.Add(handle);

return handle;
}

/// <summary>
Expand All @@ -587,10 +611,16 @@ public static MotionHandle BindToTMPCharColorA<TOptions, TAdapter>(this MotionBu
where TAdapter : unmanaged, IMotionAdapter<float, TOptions>
{
Error.IsNull(text);
return builder.BindWithState(text, (x, target) =>

var animator = TextMeshProMotionAnimator.Get(text);
animator.EnsureCapacity(charIndex + 1);
var handle = builder.BindWithState(animator, (x, target) =>
{
TextMeshProHelper.SetCharColorA(target, charIndex, x);
animator.charInfoArray[charIndex].color.a = x;
});
animator.motionHandleList.Add(handle);

return handle;
}

/// <summary>
Expand All @@ -607,10 +637,16 @@ public static MotionHandle BindToTMPCharPosition<TOptions, TAdapter>(this Motion
where TAdapter : unmanaged, IMotionAdapter<Vector3, TOptions>
{
Error.IsNull(text);
return builder.BindWithState(text, (x, target) =>

var animator = TextMeshProMotionAnimator.Get(text);
animator.EnsureCapacity(charIndex + 1);
var handle = builder.BindWithState(animator, (x, target) =>
{
TextMeshProHelper.SetCharPosition(target, charIndex, x);
animator.charInfoArray[charIndex].offset = x;
});
animator.motionHandleList.Add(handle);

return handle;
}

/// <summary>
Expand All @@ -627,10 +663,16 @@ public static MotionHandle BindToTMPCharRotation<TOptions, TAdapter>(this Motion
where TAdapter : unmanaged, IMotionAdapter<Quaternion, TOptions>
{
Error.IsNull(text);
return builder.BindWithState(text, (x, target) =>

var animator = TextMeshProMotionAnimator.Get(text);
animator.EnsureCapacity(charIndex + 1);
var handle = builder.BindWithState(animator, (x, target) =>
{
TextMeshProHelper.SetCharRotation(target, charIndex, x);
animator.charInfoArray[charIndex].rotation = x;
});
animator.motionHandleList.Add(handle);

return handle;
}

/// <summary>
Expand All @@ -647,10 +689,16 @@ public static MotionHandle BindToTMPCharEulerAngles<TOptions, TAdapter>(this Mot
where TAdapter : unmanaged, IMotionAdapter<Vector3, TOptions>
{
Error.IsNull(text);
return builder.BindWithState(text, (x, target) =>

var animator = TextMeshProMotionAnimator.Get(text);
animator.EnsureCapacity(charIndex + 1);
var handle = builder.BindWithState(animator, (x, target) =>
{
TextMeshProHelper.SetCharRotation(target, charIndex, Quaternion.Euler(x));
animator.charInfoArray[charIndex].rotation = Quaternion.Euler(x);
});
animator.motionHandleList.Add(handle);

return handle;
}

/// <summary>
Expand All @@ -667,10 +715,16 @@ public static MotionHandle BindToTMPCharScale<TOptions, TAdapter>(this MotionBui
where TAdapter : unmanaged, IMotionAdapter<Vector3, TOptions>
{
Error.IsNull(text);
return builder.BindWithState(text, (x, target) =>

var animator = TextMeshProMotionAnimator.Get(text);
animator.EnsureCapacity(charIndex + 1);
var handle = builder.BindWithState(animator, (x, target) =>
{
TextMeshProHelper.SetCharScale(target, charIndex, x);
animator.charInfoArray[charIndex].scale = x;
});
animator.motionHandleList.Add(handle);

return handle;
}
}
}
Expand Down

This file was deleted.

Loading