From 38da622e62051afb829e888359c86e2db6b299c5 Mon Sep 17 00:00:00 2001 From: CroakFang <1605296300@qq.com> Date: Tue, 13 Sep 2022 13:48:30 +0800 Subject: [PATCH] Add animation transition --- Assets/Scripts/UmaViewerBuilder.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Assets/Scripts/UmaViewerBuilder.cs b/Assets/Scripts/UmaViewerBuilder.cs index 1ed521c..752083c 100644 --- a/Assets/Scripts/UmaViewerBuilder.cs +++ b/Assets/Scripts/UmaViewerBuilder.cs @@ -832,11 +832,7 @@ public class UmaViewerBuilder : MonoBehaviour private void LoadAnimation(AnimationClip clip) { - CurrentUMAContainer.OverrideController["clip_1"] = CurrentUMAContainer.OverrideController["clip_2"]; - var lastTime = CurrentUMAContainer.UmaAnimator.GetCurrentAnimatorStateInfo(0).normalizedTime; - CurrentUMAContainer.UmaAnimator.Play("motion_1", 0, lastTime); bool needTransit = false; - if (clip.name.EndsWith("_loop")) { var motion_s = Main.AbList.FirstOrDefault(a => a.Name.EndsWith(clip.name.Replace("_loop", "_s"))); @@ -847,6 +843,9 @@ public class UmaViewerBuilder : MonoBehaviour RecursiveLoadAsset(motion_e); RecursiveLoadAsset(motion_s); } + CurrentUMAContainer.OverrideController["clip_1"] = CurrentUMAContainer.OverrideController["clip_2"]; + var lastTime = CurrentUMAContainer.UmaAnimator.GetCurrentAnimatorStateInfo(0).normalizedTime; + CurrentUMAContainer.UmaAnimator.Play("motion_1", 0, lastTime); CurrentUMAContainer.OverrideController["clip_2"] = clip; CurrentUMAContainer.UmaAnimator.SetTrigger(needTransit ? "next_s" : "next"); } @@ -860,9 +859,13 @@ public class UmaViewerBuilder : MonoBehaviour } else { + CurrentUMAContainer.OverrideController["clip_1"] = CurrentUMAContainer.OverrideController["clip_2"]; + var lastTime = CurrentUMAContainer.UmaAnimator.GetCurrentAnimatorStateInfo(0).normalizedTime; + CurrentUMAContainer.UmaAnimator.Play("motion_1", 0, lastTime); CurrentUMAContainer.OverrideController["clip_2"] = clip; CurrentUMAContainer.UmaAnimator.SetTrigger(needTransit ? "next_s" : "next"); } + } private void UnloadBundle(AssetBundle bundle, bool unloadAllObjects)