Add builder creation to extension methods
RomanPlotnikov opened this issue · 2 comments
RomanPlotnikov commented
It will probably be more intuitive and beautiful if the static class is hidden in the extension method as in DOTween.
Example: transform.CreateMotion(transform.position, (Vector3.forward * 10.0F), 1.0F).BindToPosition();
Code:
public static class ObjectExtensions
{
public static (TObject SystemObject, MotionBuilder<Vector3, NoOptions, Vector3MotionAdapter> MotionBuilder) CreateMotion<TObject>(this TObject systemObject, Vector3 startValue, Vector3 endValue, Single duration)
{
return (systemObject, LMotion.Create(startValue, endValue, duration));
}
}
public static class TransformExtensions
{
public static MotionHandle BindToPosition(this (Transform Transform, MotionBuilder<Vector3, NoOptions, Vector3MotionAdapter> MotionBuilder) builder)
{
return builder.MotionBuilder.BindWithState(builder.Transform, ((position, transform) => transform.position = position));
}
}
AnnulusGames commented
LitMotion's avoidance of extension methods is intentional. This helps improve readability by avoiding naming conflicts with other libraries and unifying the entry point to LMotion.
AnnulusGames commented
Of course, it is possible to create extension methods on the user side, but I don't think it is necessary to include them in this library. Extension methods like BindTo-()
would be sufficient.