Skip to content

Commit

Permalink
feat: instant animator looping
Browse files Browse the repository at this point in the history
  • Loading branch information
buger404 committed Aug 12, 2024
1 parent bf2a141 commit 1719732
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Scripts/Milease/Core/Animator/MilInstantAnimator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public class MilInstantAnimator
public RuntimeAnimationPart.AnimationResetMode DefaultResetMode =
RuntimeAnimationPart.AnimationResetMode.ResetToOriginalState;

public bool Loop { get; set; } = false;

internal Action PlayCallback;

internal int PlayIndex = 0;
Expand All @@ -36,6 +38,12 @@ public MilInstantAnimator UsingResetMode(RuntimeAnimationPart.AnimationResetMode
return this;
}

public MilInstantAnimator EnableLooping()
{
Loop = true;
return this;
}

public MilInstantAnimator Delayed(float time)
{
foreach (var part in Collection[^1])
Expand Down
4 changes: 4 additions & 0 deletions Scripts/Milease/Core/Manager/MilInstantAnimatorManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ private void Update()
Animations.RemoveAt(i);
i--;
cnt--;
if (set.Loop)
{
set.Play(set.PlayCallback);
}
}
else
{
Expand Down

0 comments on commit 1719732

Please sign in to comment.