Skip to content
Open
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 @@ -95,6 +95,7 @@ VisualElement CreateSettingsPanel()
var box = CreateBox("Settings");
box.Add(new PropertyField(serializedObject.FindProperty("playOnAwake")));
box.Add(new PropertyField(serializedObject.FindProperty("animationMode")));
box.Add(new PropertyField(serializedObject.FindProperty("preserve")));
return box;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ enum AnimationMode

[SerializeField] bool playOnAwake = true;
[SerializeField] AnimationMode animationMode;
[SerializeField] bool preserve = true;

[SerializeReference]
LitMotionAnimationComponent[] components;
Expand All @@ -41,7 +42,8 @@ void MoveNextMotion()

if (isActive)
{
handle.Preserve();
if (preserve)
handle.Preserve();
MotionManager.GetManagedDataRef(handle, false).OnCompleteAction += MoveNextMotion;
}

Expand Down Expand Up @@ -105,7 +107,8 @@ public void Play()

if (handle.IsActive())
{
handle.Preserve();
if (preserve)
handle.Preserve();
}

playingComponents.Add(component);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,25 @@ public abstract class PropertyAnimationComponent<TObject, TValue, TOptions, TAda
[SerializeField] TObject target;
[SerializeField] SerializableMotionSettings<TValue, TOptions> settings;
[SerializeField] bool relative;
enum InterruptionValueState { StartValue, Stay, EndValue }
[SerializeField] InterruptionValueState interruptionValueState;

TValue startValue;
TValue startValue, endValue;

public override void OnStop()
{
if (target == null) return;
SetValue(target, startValue);
switch (interruptionValueState)
{
case InterruptionValueState.StartValue:
SetValue(target, startValue);
break;
case InterruptionValueState.Stay:
break;
case InterruptionValueState.EndValue:
SetValue(target, endValue);
break;
}
}

public override MotionHandle Play()
Expand All @@ -31,6 +43,7 @@ public override MotionHandle Play()

if (relative)
{
endValue = GetRelativeValue(startValue, settings.EndValue);
handle = LMotion.Create<TValue, TOptions, TAdapter>(settings)
.Bind(this, (x, state) =>
{
Expand All @@ -39,6 +52,7 @@ public override MotionHandle Play()
}
else
{
endValue = settings.EndValue;
handle = LMotion.Create<TValue, TOptions, TAdapter>(settings)
.Bind(this, (x, state) =>
{
Expand Down