Skip to content

Commit

Permalink
Add: handle.Duration and handle.Loops
Browse files Browse the repository at this point in the history
  • Loading branch information
yn01-dev committed Dec 21, 2024
1 parent 67e0b9f commit aae37fc
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down
24 changes: 23 additions & 1 deletion src/LitMotion/Assets/LitMotion/Runtime/MotionHandle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,39 @@ public readonly double Time
}
}

/// <summary>
/// The duration of the motion
/// </summary>
public readonly float Duration
{
get
{
return MotionManager.GetDataRef(this, false).Parameters.Duration;
}
}

/// <summary>
/// The total duration of the motion
/// </summary>
public readonly double Duration
public readonly double TotalDuration
{
get
{
return MotionManager.GetDataRef(this, false).Parameters.TotalDuration;
}
}

/// <summary>
/// The number of loops
/// </summary>
public readonly int Loops
{
get
{
return MotionManager.GetDataRef(this, false).Parameters.Loops;
}
}

/// <summary>
/// The number of loops completed
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/LitMotion/Assets/Sandbox/Sandbox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void Start()
.Preserve()
.AddTo(this);

slider.maxValue = (float)handle.Duration;
slider.maxValue = (float)handle.TotalDuration;
}

void Update()
Expand Down

0 comments on commit aae37fc

Please sign in to comment.