diff --git a/src/LitMotion/Assets/LitMotion.Animation/Editor/LitMotionAnimationEditor.cs b/src/LitMotion/Assets/LitMotion.Animation/Editor/LitMotionAnimationEditor.cs index 4e5d1cec..e9bcd1cd 100644 --- a/src/LitMotion/Assets/LitMotion.Animation/Editor/LitMotionAnimationEditor.cs +++ b/src/LitMotion/Assets/LitMotion.Animation/Editor/LitMotionAnimationEditor.cs @@ -167,9 +167,9 @@ VisualElement CreateComponentsPanel() var handle = component.TrackedHandle; - if (handle.IsActive() && !double.IsInfinity(handle.Duration)) + if (handle.IsActive() && !double.IsInfinity(handle.TotalDuration)) { - views[i].Progress = Mathf.InverseLerp(0f, (float)handle.Duration, (float)handle.Time); + views[i].Progress = Mathf.InverseLerp(0f, (float)handle.TotalDuration, (float)handle.Time); } else { diff --git a/src/LitMotion/Assets/LitMotion/Runtime/Internal/MotionStorage.cs b/src/LitMotion/Assets/LitMotion/Runtime/Internal/MotionStorage.cs index 1698f88d..55d55177 100644 --- a/src/LitMotion/Assets/LitMotion/Runtime/Internal/MotionStorage.cs +++ b/src/LitMotion/Assets/LitMotion/Runtime/Internal/MotionStorage.cs @@ -422,7 +422,7 @@ public void AddToSequence(MotionHandle handle, out double motionDuration) throw new ArgumentException("Cannot add a running motion to a sequence."); } - motionDuration = handle.Duration; + motionDuration = handle.TotalDuration; if (double.IsInfinity(motionDuration)) { throw new ArgumentException("Cannot add an infinitely looping motion to a sequence."); diff --git a/src/LitMotion/Assets/LitMotion/Runtime/MotionHandle.cs b/src/LitMotion/Assets/LitMotion/Runtime/MotionHandle.cs index e84198a1..3cccc9ac 100644 --- a/src/LitMotion/Assets/LitMotion/Runtime/MotionHandle.cs +++ b/src/LitMotion/Assets/LitMotion/Runtime/MotionHandle.cs @@ -42,10 +42,21 @@ public readonly double Time } } + /// + /// The duration of the motion + /// + public readonly float Duration + { + get + { + return MotionManager.GetDataRef(this, false).Parameters.Duration; + } + } + /// /// The total duration of the motion /// - public readonly double Duration + public readonly double TotalDuration { get { @@ -53,6 +64,17 @@ public readonly double Duration } } + /// + /// The number of loops + /// + public readonly int Loops + { + get + { + return MotionManager.GetDataRef(this, false).Parameters.Loops; + } + } + /// /// The number of loops completed /// diff --git a/src/LitMotion/Assets/Sandbox/Sandbox.cs b/src/LitMotion/Assets/Sandbox/Sandbox.cs index 3f484978..2d796a6b 100644 --- a/src/LitMotion/Assets/Sandbox/Sandbox.cs +++ b/src/LitMotion/Assets/Sandbox/Sandbox.cs @@ -23,7 +23,7 @@ void Start() .Preserve() .AddTo(this); - slider.maxValue = (float)handle.Duration; + slider.maxValue = (float)handle.TotalDuration; } void Update()