This commit is contained in:
CroakFang
2022-11-03 21:39:20 +08:00
parent af5ccfd799
commit 495429e962
4 changed files with 51 additions and 12 deletions
-2
View File
@@ -7,8 +7,6 @@ using UnityEngine;
public class UmaContainer : MonoBehaviour
{
UmaViewerUI UI => UmaViewerUI.Instance;
public JObject CharaData;
public GameObject Body;
public GameObject Tail;
+14 -1
View File
@@ -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
+14 -4
View File
@@ -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<UmaUIContainer>();
@@ -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;
}
/// <summary> Toggles one object ON and all others from UI.TogglablePanels list OFF </summary>
@@ -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()
@@ -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<Animator>();
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();
}
}
}