From 495429e9628f05f04fff6bc11ae52f6190b97745 Mon Sep 17 00:00:00 2001 From: CroakFang <1605296300@qq.com> Date: Thu, 3 Nov 2022 21:39:20 +0800 Subject: [PATCH] bug fix --- Assets/Scripts/UmaContainer.cs | 2 -- Assets/Scripts/UmaViewerBuilder.cs | 15 +++++++++- Assets/Scripts/UmaViewerUI.cs | 18 +++++++++--- .../umamusume/Gallop/FaceDrivenKeyTarget.cs | 28 +++++++++++++++---- 4 files changed, 51 insertions(+), 12 deletions(-) diff --git a/Assets/Scripts/UmaContainer.cs b/Assets/Scripts/UmaContainer.cs index c0916c7..f51f687 100644 --- a/Assets/Scripts/UmaContainer.cs +++ b/Assets/Scripts/UmaContainer.cs @@ -7,8 +7,6 @@ using UnityEngine; public class UmaContainer : MonoBehaviour { - UmaViewerUI UI => UmaViewerUI.Instance; - public JObject CharaData; public GameObject Body; public GameObject Tail; diff --git a/Assets/Scripts/UmaViewerBuilder.cs b/Assets/Scripts/UmaViewerBuilder.cs index a9a4d59..48f3b5a 100644 --- a/Assets/Scripts/UmaViewerBuilder.cs +++ b/Assets/Scripts/UmaViewerBuilder.cs @@ -951,15 +951,28 @@ public class UmaViewerBuilder : MonoBehaviour CurrentUMAContainer.UmaAnimator.Play("motion_1", -1); CurrentUMAContainer.UmaAnimator.SetTrigger(needTransit ? "next_s" : "next"); } + else if (clip.name.Contains("face")) + { + clip.wrapMode = WrapMode.Loop; + CurrentUMAContainer.FaceOverrideController["clip_1"] = clip; + CurrentUMAContainer.FaceDrivenKeyTarget.ResetLocator(); + CurrentUMAContainer.isAnimatorControl = true; + CurrentUMAContainer.UmaFaceAnimator.Play("motion_1", 0, 0); + } else { CurrentUMAContainer.OverrideController["clip_1"] = CurrentUMAContainer.OverrideController["clip_2"]; var lastTime = CurrentUMAContainer.UmaAnimator.GetCurrentAnimatorStateInfo(0).normalizedTime; CurrentUMAContainer.OverrideController["clip_2"] = clip; - // If Cut-in, play immediately without state interpolation if (clip.name.Contains("crd")) { + clip.wrapMode = WrapMode.Loop; + var facialMotion = Main.AbMotions.FirstOrDefault(a => a.Name.EndsWith(clip.name + "_face")); + if (facialMotion != null) + { + RecursiveLoadAsset(facialMotion); + } CurrentUMAContainer.UmaAnimator.Play("motion_2", 0, 0); } else diff --git a/Assets/Scripts/UmaViewerUI.cs b/Assets/Scripts/UmaViewerUI.cs index fc6ff14..7747a60 100644 --- a/Assets/Scripts/UmaViewerUI.cs +++ b/Assets/Scripts/UmaViewerUI.cs @@ -495,6 +495,7 @@ public class UmaViewerUI : MonoBehaviour var filteredList = Main.AbList.Where(a => a.Name.StartsWith(UmaDatabaseController.MotionPath) && !a.Name.Contains($"mirror") && (mini ? a.Name.Contains($"mini") : !a.Name.Contains($"mini")) + && !a.Name.Contains($"facial") && !a.Name.Contains($"_cam") && !a.Name.EndsWith($"_s") && !a.Name.EndsWith($"_e") @@ -531,7 +532,7 @@ public class UmaViewerUI : MonoBehaviour else { //Common animations - foreach (var entry in filteredList.Where(a => a.Name.Contains($"chara/chr{umaId}"))) + foreach (var entry in filteredList.Where(a => a.Name.Contains($"chara/chr{umaId}") && !a.Name.Contains("pose"))) { var entryInstance = entry; var container = Instantiate(UmaContainerPrefab, animationList.content).GetComponent(); @@ -564,6 +565,7 @@ public class UmaViewerUI : MonoBehaviour AnimationSlider.SetValueWithoutNotify(0); // Reset settings by Panel Builder.CurrentUMAContainer.UmaAnimator.speed = AnimationSpeedSlider.value; + Builder.CurrentUMAContainer.UmaFaceAnimator.speed = AnimationSpeedSlider.value; } /// Toggles one object ON and all others from UI.TogglablePanels list OFF @@ -643,7 +645,6 @@ public class UmaViewerUI : MonoBehaviour { if (Builder.CurrentAudioSources.Count>0) { - AudioSource MiaiSource = Builder.CurrentAudioSources[0]; foreach (AudioSource source in Builder.CurrentAudioSources) { if (source.clip) @@ -660,20 +661,25 @@ public class UmaViewerUI : MonoBehaviour if (Builder.OverrideController.animationClips.Length > 0) { var animator = Builder.CurrentUMAContainer.UmaAnimator; + var animator_face = Builder.CurrentUMAContainer.UmaFaceAnimator; var AnimeState = animator.GetCurrentAnimatorStateInfo(0); var state = animator.speed > 0f; if (state) { animator.speed = 0; + animator_face.speed = 0; } else if (AnimeState.normalizedTime < 1f) { animator.speed = AnimationSpeedSlider.value; + animator_face.speed = AnimationSpeedSlider.value; } else { animator.speed = AnimationSpeedSlider.value; animator.Play(0, -1, 0); + animator_face.speed = AnimationSpeedSlider.value; + animator_face.Play(0, -1, 0); } } @@ -683,13 +689,16 @@ public class UmaViewerUI : MonoBehaviour { if (!Builder.CurrentUMAContainer || !Builder.CurrentUMAContainer.UmaAnimator) return; var animator = Builder.CurrentUMAContainer.UmaAnimator; + var animator_face = Builder.CurrentUMAContainer.UmaFaceAnimator; if (animator != null) { var AnimeClip = Builder.CurrentUMAContainer.OverrideController["clip_2"]; - + // Pause and Seek; - Builder.CurrentUMAContainer.UmaAnimator.speed = 0; + animator.speed = 0; animator.Play(0, -1, val); + animator_face.speed = 0; + animator_face.Play(0, -1, val); AnimationProgressText.text = string.Format("{0} / {1}", ToFrameFormat(val * AnimeClip.length, AnimeClip.frameRate), ToFrameFormat(AnimeClip.length, AnimeClip.frameRate)); } @@ -700,6 +709,7 @@ public class UmaViewerUI : MonoBehaviour AnimationSpeedText.text = string.Format("Animation Speed: {0:F2}", val); if (!Builder.CurrentUMAContainer || !Builder.CurrentUMAContainer.UmaAnimator) return; Builder.CurrentUMAContainer.UmaAnimator.speed = val; + Builder.CurrentUMAContainer.UmaFaceAnimator.speed = val; } public void ResetAudioPlayer() diff --git a/Assets/Scripts/umamusume/Gallop/FaceDrivenKeyTarget.cs b/Assets/Scripts/umamusume/Gallop/FaceDrivenKeyTarget.cs index d38b65b..34072f7 100644 --- a/Assets/Scripts/umamusume/Gallop/FaceDrivenKeyTarget.cs +++ b/Assets/Scripts/umamusume/Gallop/FaceDrivenKeyTarget.cs @@ -135,7 +135,7 @@ namespace Gallop SetupLocator("Eye_R_Base_Ctrl", "Eye_R__", EyeMorphs.FindAll(a => a.direction == false)); SetupLocator("Eyebrow_L_Base_Ctrl", "Eyebrow_L__", EyeBrowMorphs.FindAll(a => a.direction == true)); SetupLocator("Eyebrow_R_Base_Ctrl", "Eyebrow_R__", EyeBrowMorphs.FindAll(a => a.direction == false)); - SetupLocator("Mouth_Base_Ctrl", "Mouth__", EyeBrowMorphs.FindAll(a => a.direction == false)); + SetupLocator("Mouth_Base_Ctrl", "Mouth__", MouthMorphs.FindAll(a => a.direction == false)); Container.UmaFaceAnimator = DrivenKeyLocator.AddComponent(); Container.UmaFaceAnimator.avatar = AvatarBuilder.BuildGenericAvatar(DrivenKeyLocator, "DrivenKeyLocator"); @@ -259,20 +259,38 @@ namespace Gallop { EyeBrowMorphs.ForEach(morph => { - morph.weight = morph.locator.transform.localPosition.x; + morph.weight = morph.locator.transform.localPosition.x * -100; }); EyeMorphs.ForEach(morph => { - morph.weight = morph.locator.transform.localPosition.x; + morph.weight = morph.locator.transform.localPosition.x * -100; }); MouthMorphs.ForEach(morph => { - if(morph.locator) - morph.weight = morph.locator.transform.localPosition.x; + morph.weight = morph.locator.transform.localPosition.x * -100; }); ChangeMorph(); } + public void ResetLocator() + { + EyeBrowMorphs.ForEach(morph => + { + morph.weight = 0; + morph.locator.transform.localPosition = Vector3.zero; + }); + EyeMorphs.ForEach(morph => + { + morph.weight = 0; + morph.locator.transform.localPosition = Vector3.zero; + }); + MouthMorphs.ForEach(morph => + { + morph.weight = 0; + morph.locator.transform.localPosition = Vector3.zero; + }); + ChangeMorph(); + } } }