From 590568cb109466872e1dd3a5d04b2a68561db75f Mon Sep 17 00:00:00 2001 From: gamer-jp <64856190+gamer-jp@users.noreply.github.com> Date: Thu, 29 Sep 2022 04:26:15 +0900 Subject: [PATCH] loop support --- Assets/Scripts/UmaViewerUI.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/UmaViewerUI.cs b/Assets/Scripts/UmaViewerUI.cs index ac9414d..b2e227b 100644 --- a/Assets/Scripts/UmaViewerUI.cs +++ b/Assets/Scripts/UmaViewerUI.cs @@ -580,6 +580,8 @@ public class UmaViewerUI : MonoBehaviour if (animator != null) { var AnimeClip = Builder.CurrentUMAContainer.OverrideController["clip_2"]; + + // Pause and Seek; Builder.CurrentUMAContainer.UmaAnimator.speed = 0; animator.Play(0, -1, val); @@ -613,13 +615,16 @@ public class UmaViewerUI : MonoBehaviour { if(Builder.CurrentUMAContainer.OverrideController["clip_2"].name != "clip_2") { + bool isLoop = Builder.CurrentUMAContainer.OverrideController["clip_2"].name.EndsWith("_loop"); var AnimeState = Builder.CurrentUMAContainer.UmaAnimator.GetCurrentAnimatorStateInfo(0); var AnimeClip = Builder.CurrentUMAContainer.OverrideController["clip_2"]; if (AnimeClip && Builder.CurrentUMAContainer.UmaAnimator.speed != 0) { + var normalizedTime = (isLoop) ? Mathf.Repeat(AnimeState.normalizedTime, 1) : Mathf.Min(AnimeState.normalizedTime, 1); + AnimationTitleText.text = AnimeClip.name; - AnimationProgressText.text = string.Format("{0} / {1}", ToFrameFormat(Mathf.Repeat(AnimeState.normalizedTime, 1) * AnimeClip.length, AnimeClip.frameRate), ToFrameFormat(AnimeClip.length, AnimeClip.frameRate)); - AnimationSlider.SetValueWithoutNotify(Mathf.Repeat(AnimeState.normalizedTime, 1)); + AnimationProgressText.text = string.Format("{0} / {1}", ToFrameFormat(normalizedTime * AnimeClip.length, AnimeClip.frameRate), ToFrameFormat(AnimeClip.length, AnimeClip.frameRate)); + AnimationSlider.SetValueWithoutNotify(normalizedTime); } } }