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 MotionSettings and remove MotionBuilder.Preserve() #149

Merged
merged 8 commits into from
Nov 24, 2024

Conversation

yn01-dev
Copy link
Owner

This PR adds MotionSettings<TValue, TOptions>. This makes it possible to save settings in advance when creating motions with the same parameters multiple times. MotionSettings can be created from MotionBuilder in the same way as normal motions.

var setting = LMotion.Create(0f, 10f, 2f)
    .WithEase(Ease.OutQuad)
    .WithLoops(-1, LoopType.Yoyo)
    .WithScheduler(MotionScheduler.FixedUpdate)
    .ToMotionSettings();

LMotion.Create(setting)
    .Bind(x => {  });

Also, SerializableMotionSettings are MotionSettings that can be edited from the Inspector.

using LitMotion;
using LitMotion.Extensions;
using UnityEngine;

public class Sandbox : MonoBehaviour
{
    [SerializeField] Transform target;
    [SerializeField] SerializableMotionSettings<float, NoOptions> settings;

    void Start()
    {
        LMotion.Create(settings)
            .WithOnComplete(() => Debug.Log("Complete"))
            .BindToPositionX(target)
            .AddTo(target);
    }
}

image

@yn01-dev
Copy link
Owner Author

I have also removed MotionBuilder.Preserve(). Similar use cases can be handled by MotionSettings. Also, MotionBuilder.Preserve() is confusing with MotionHandle.Preserve(), which was added in #146.

@yn01-dev yn01-dev changed the title Add: MotionSettings and SerializableMotionSettings Add MotionSettings and remove MotionBuilder.Preserve() Nov 24, 2024
@yn01-dev yn01-dev merged commit 8218cc3 into v2.0 Nov 24, 2024
@yn01-dev yn01-dev deleted the motion-settings branch November 24, 2024 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant