diff --git a/Assets/Scenes/Version2.unity b/Assets/Scenes/Version2.unity index 3bae62a..439f600 100644 --- a/Assets/Scenes/Version2.unity +++ b/Assets/Scenes/Version2.unity @@ -2635,7 +2635,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0.5} m_AnchorMax: {x: 1, y: 0.5} - m_AnchoredPosition: {x: -0.5, y: 252.35} + m_AnchoredPosition: {x: -0.5, y: 242} m_SizeDelta: {x: -85, y: 30} m_Pivot: {x: 0.5, y: 1} --- !u!114 &212377233 @@ -3871,7 +3871,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: -104.3} + m_AnchoredPosition: {x: 0, y: -99} m_SizeDelta: {x: -224, y: 30} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &292348637 @@ -13368,7 +13368,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: -151.5} + m_AnchoredPosition: {x: 0, y: -149} m_SizeDelta: {x: -16, y: 25} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &994851660 @@ -13416,7 +13416,7 @@ MonoBehaviour: m_HandleRect: {fileID: 1647140268} m_Direction: 0 m_MinValue: 0 - m_MaxValue: 1 + m_MaxValue: 2 m_WholeNumbers: 0 m_Value: 1 m_OnValueChanged: @@ -15672,7 +15672,7 @@ MonoBehaviour: m_HandleRect: {fileID: 1882365342} m_Direction: 2 m_Value: 1 - m_Size: 0.8225314 + m_Size: 0.74480647 m_NumberOfSteps: 0 m_OnValueChanged: m_PersistentCalls: @@ -20819,8 +20819,8 @@ RectTransform: m_Father: {fileID: 1145728918} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 1, y: 0} - m_AnchorMax: {x: 1, y: 1} + m_AnchorMin: {x: 0.5, y: 0} + m_AnchorMax: {x: 0.5, y: 1} m_AnchoredPosition: {x: -10, y: 0} m_SizeDelta: {x: 20, y: -4} m_Pivot: {x: 0, y: 0.5} @@ -24493,7 +24493,7 @@ RectTransform: m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} + m_AnchorMax: {x: 0.5, y: 1} m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 10, y: 0} m_Pivot: {x: 0.5, y: 0.5} @@ -32306,7 +32306,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: -50} + m_AnchoredPosition: {x: 0, y: -80} m_SizeDelta: {x: 0, y: -100} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &6878219667498913897 @@ -32703,7 +32703,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0.5} m_AnchorMax: {x: 1, y: 0.5} - m_AnchoredPosition: {x: -0.5, y: 219} + m_AnchoredPosition: {x: -0.5, y: 201} m_SizeDelta: {x: -85, y: 30} m_Pivot: {x: 0.5, y: 1} --- !u!114 &6878219667641514016 @@ -34109,7 +34109,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: -50} + m_AnchoredPosition: {x: 0, y: -80} m_SizeDelta: {x: 0, y: -100} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &6878219668012581467 diff --git a/Assets/Scripts/UmaViewerBuilder.cs b/Assets/Scripts/UmaViewerBuilder.cs index a7f359b..cfef99c 100644 --- a/Assets/Scripts/UmaViewerBuilder.cs +++ b/Assets/Scripts/UmaViewerBuilder.cs @@ -179,8 +179,9 @@ public class UmaViewerBuilder : MonoBehaviour int head_id; string head_costumeId; int tailId = (int)charaData["tailModelId"]; - - if (id == 9006) tailId = -1;//The tailId of 9006 is 1, but the character has no tail + + //The tailId of 9006 is 1, but the character has no tail + if (id == 9006) tailId = -1; if (UI.isHeadFix && CurrentHead != null) { @@ -910,11 +911,12 @@ 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_1"] = CurrentUMAContainer.OverrideController["clip_2"]; CurrentUMAContainer.OverrideController["clip_2"] = clip; + + CurrentUMAContainer.UmaAnimator.Play("motion_1", 0, lastTime); CurrentUMAContainer.UmaAnimator.SetTrigger(needTransit ? "next_s" : "next"); } else if(clip.name.EndsWith("_S")) @@ -939,9 +941,9 @@ public class UmaViewerBuilder : MonoBehaviour else { CurrentUMAContainer.UmaAnimator.Play("motion_1", 0, lastTime); + CurrentUMAContainer.UmaAnimator.SetTrigger(needTransit ? "next_s" : "next"); } - CurrentUMAContainer.UmaAnimator.SetTrigger(needTransit ? "next_s" : "next"); } } diff --git a/Assets/Scripts/UmaViewerUI.cs b/Assets/Scripts/UmaViewerUI.cs index 32b0c9a..ba95e59 100644 --- a/Assets/Scripts/UmaViewerUI.cs +++ b/Assets/Scripts/UmaViewerUI.cs @@ -310,7 +310,6 @@ public class UmaViewerUI : MonoBehaviour } } - public void SetCriWare(bool value) { isCriware = value; @@ -319,7 +318,6 @@ public class UmaViewerUI : MonoBehaviour public void SetHeadFix(bool value) { isHeadFix = value; - UnityEngine.Debug.Log(isHeadFix); } void ListLiveSounds(int songid) @@ -456,7 +454,8 @@ public class UmaViewerUI : MonoBehaviour public void LoadedAnimation() { - AnimationSlider.value = 0f; + if (!Builder.CurrentUMAContainer || !Builder.CurrentUMAContainer.UmaAnimator) return; + AnimationSlider.SetValueWithoutNotify(0); // Reset settings by Panel Builder.CurrentUMAContainer.UmaAnimator.speed = AnimationSpeedSlider.value; } @@ -501,7 +500,6 @@ public class UmaViewerUI : MonoBehaviour { cySpring.EnablePhysics(isOn); } - } } @@ -547,12 +545,12 @@ public class UmaViewerUI : MonoBehaviour source.time = source.clip.length * val; } } - } } public void AnimationPause() { + if (!Builder.CurrentUMAContainer || !Builder.CurrentUMAContainer.UmaAnimator) return; if (Builder.OverrideController.animationClips.Length > 0) { var animator = Builder.CurrentUMAContainer.UmaAnimator; @@ -577,6 +575,7 @@ public class UmaViewerUI : MonoBehaviour public void AnimationProgressChange(float val) { + if (!Builder.CurrentUMAContainer || !Builder.CurrentUMAContainer.UmaAnimator) return; var animator = Builder.CurrentUMAContainer.UmaAnimator; if (animator != null) { @@ -590,12 +589,9 @@ public class UmaViewerUI : MonoBehaviour public void AnimationSpeedChange(float val) { - var animator = Builder.CurrentUMAContainer.UmaAnimator; - if (animator != null) - { - Builder.CurrentUMAContainer.UmaAnimator.speed = val; - AnimationSpeedText.text = $"Animation Speed: {val}"; - } + AnimationSpeedText.text = string.Format("Animation Speed: {0:F2}", val); + if (!Builder.CurrentUMAContainer || !Builder.CurrentUMAContainer.UmaAnimator) return; + Builder.CurrentUMAContainer.UmaAnimator.speed = val; } private void Update() @@ -612,15 +608,19 @@ public class UmaViewerUI : MonoBehaviour } } - if (Builder.CurrentUMAContainer != null && Builder.CurrentUMAContainer.UmaAnimator != null && Builder.CurrentUMAContainer.OverrideController != null) + + if (Builder.CurrentUMAContainer != null && Builder.CurrentUMAContainer.OverrideController != null) { - var AnimeState = Builder.CurrentUMAContainer.UmaAnimator.GetCurrentAnimatorStateInfo(0); - var AnimeClip = Builder.CurrentUMAContainer.OverrideController["clip_2"]; - if (AnimeClip && Builder.CurrentUMAContainer.UmaAnimator.speed != 0) + if(Builder.CurrentUMAContainer.OverrideController["clip_2"].name != "clip_2") { - AnimationTitleText.text = AnimeClip.name; - AnimationProgressText.text = string.Format("{0} / {1}", ToTimeFormat(AnimeState.normalizedTime * AnimeClip.length), ToTimeFormat(AnimeClip.length)); - AnimationSlider.SetValueWithoutNotify(AnimeState.normalizedTime); + var AnimeState = Builder.CurrentUMAContainer.UmaAnimator.GetCurrentAnimatorStateInfo(0); + var AnimeClip = Builder.CurrentUMAContainer.OverrideController["clip_2"]; + if (AnimeClip && Builder.CurrentUMAContainer.UmaAnimator.speed != 0) + { + AnimationTitleText.text = AnimeClip.name; + AnimationProgressText.text = string.Format("{0} / {1}", ToTimeFormat(Mathf.Repeat(AnimeState.normalizedTime, 1) * AnimeClip.length), ToTimeFormat(AnimeClip.length)); + AnimationSlider.SetValueWithoutNotify(Mathf.Repeat(AnimeState.normalizedTime, 1)); + } } } }