Skip to content

Commit

Permalink
Merge pull request #198 from AnnulusGames/feat-tmp-extensions
Browse files Browse the repository at this point in the history
Add: TMP_Text spacing bind extensions
  • Loading branch information
AnnulusGames authored Jan 21, 2025
2 parents f7df496 + d1a75fb commit 05bc238
Showing 1 changed file with 76 additions and 0 deletions.
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

0 comments on commit 05bc238

Please sign in to comment.