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

Add: TMP_Text spacing bind extensions #198

Merged
merged 1 commit into from
Jan 21, 2025
Merged
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 @@ -72,6 +72,82 @@ public static MotionHandle BindToMaxVisibleLines<TOptions, TAdapter>(this Motion
});
}

/// <summary>
/// Create a motion data and bind it to TMP_Text.characterSpacing
/// </summary>
/// <typeparam name="TOptions">The type of special parameters given to the motion data</typeparam>
/// <typeparam name="TAdapter">The type of adapter that support value animation</typeparam>
/// <param name="builder">This builder</param>
/// <param name="text">Target TMP_Text</param>
/// <returns>Handle of the created motion data.</returns>
public static MotionHandle BindToCharacterSpacing<TOptions, TAdapter>(this MotionBuilder<float, TOptions, TAdapter> builder, TMP_Text text)
where TOptions : unmanaged, IMotionOptions
where TAdapter : unmanaged, IMotionAdapter<float, TOptions>
{
Error.IsNull(text);
return builder.Bind(text, static (x, target) =>
{
target.characterSpacing = x;
});
}

/// <summary>
/// Create a motion data and bind it to TMP_Text.wordSpacing
/// </summary>
/// <typeparam name="TOptions">The type of special parameters given to the motion data</typeparam>
/// <typeparam name="TAdapter">The type of adapter that support value animation</typeparam>
/// <param name="builder">This builder</param>
/// <param name="text">Target TMP_Text</param>
/// <returns>Handle of the created motion data.</returns>
public static MotionHandle BindToWordSpacing<TOptions, TAdapter>(this MotionBuilder<float, TOptions, TAdapter> builder, TMP_Text text)
where TOptions : unmanaged, IMotionOptions
where TAdapter : unmanaged, IMotionAdapter<float, TOptions>
{
Error.IsNull(text);
return builder.Bind(text, static (x, target) =>
{
target.wordSpacing = x;
});
}

/// <summary>
/// Create a motion data and bind it to TMP_Text.paragraphSpacing
/// </summary>
/// <typeparam name="TOptions">The type of special parameters given to the motion data</typeparam>
/// <typeparam name="TAdapter">The type of adapter that support value animation</typeparam>
/// <param name="builder">This builder</param>
/// <param name="text">Target TMP_Text</param>
/// <returns>Handle of the created motion data.</returns>
public static MotionHandle BindToParagraphSpacing<TOptions, TAdapter>(this MotionBuilder<float, TOptions, TAdapter> builder, TMP_Text text)
where TOptions : unmanaged, IMotionOptions
where TAdapter : unmanaged, IMotionAdapter<float, TOptions>
{
Error.IsNull(text);
return builder.Bind(text, static (x, target) =>
{
target.paragraphSpacing = x;
});
}

/// <summary>
/// Create a motion data and bind it to TMP_Text.lineSpacing
/// </summary>
/// <typeparam name="TOptions">The type of special parameters given to the motion data</typeparam>
/// <typeparam name="TAdapter">The type of adapter that support value animation</typeparam>
/// <param name="builder">This builder</param>
/// <param name="text">Target TMP_Text</param>
/// <returns>Handle of the created motion data.</returns>
public static MotionHandle BindToLineSpacing<TOptions, TAdapter>(this MotionBuilder<float, TOptions, TAdapter> builder, TMP_Text text)
where TOptions : unmanaged, IMotionOptions
where TAdapter : unmanaged, IMotionAdapter<float, TOptions>
{
Error.IsNull(text);
return builder.Bind(text, static (x, target) =>
{
target.lineSpacing = x;
});
}

/// <summary>
/// Create a motion data and bind it to TMP_Text.maxVisibleWords
/// </summary>
Expand Down