From 1327ed51c6a6f16137de849f74d4cd2adbe850f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B7=A6=E5=8F=B3=E7=9C=8B?= <1918891542@qq.com> Date: Thu, 29 Sep 2022 00:45:32 +0800 Subject: [PATCH 1/3] fix bug --- Assets/Scripts/UmaViewerUI.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/Scripts/UmaViewerUI.cs b/Assets/Scripts/UmaViewerUI.cs index a7cec14..32b0c9a 100644 --- a/Assets/Scripts/UmaViewerUI.cs +++ b/Assets/Scripts/UmaViewerUI.cs @@ -612,7 +612,7 @@ public class UmaViewerUI : MonoBehaviour } } - if (Builder.CurrentUMAContainer != null && Builder.CurrentUMAContainer.OverrideController["clip_2"].name != "clip_2") + if (Builder.CurrentUMAContainer != null && Builder.CurrentUMAContainer.UmaAnimator != null && Builder.CurrentUMAContainer.OverrideController != null) { var AnimeState = Builder.CurrentUMAContainer.UmaAnimator.GetCurrentAnimatorStateInfo(0); var AnimeClip = Builder.CurrentUMAContainer.OverrideController["clip_2"]; From 48f27c044a23354d2548bb3ecd6db3623517726d Mon Sep 17 00:00:00 2001 From: CroakFang <1605296300@qq.com> Date: Thu, 29 Sep 2022 01:11:02 +0800 Subject: [PATCH 2/3] bug fix --- Assets/Scenes/Version2.unity | 22 +++++++++--------- Assets/Scripts/UmaViewerBuilder.cs | 14 +++++++----- Assets/Scripts/UmaViewerUI.cs | 36 +++++++++++++++--------------- 3 files changed, 37 insertions(+), 35 deletions(-) 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 8488e7f..4321ad1 100644 --- a/Assets/Scripts/UmaViewerBuilder.cs +++ b/Assets/Scripts/UmaViewerBuilder.cs @@ -173,8 +173,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) { @@ -887,11 +888,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")) @@ -916,9 +918,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 a7cec14..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.OverrideController["clip_2"].name != "clip_2") + + 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)); + } } } } From 9e08a76482bdfec99161cd7d11d61de475efc079 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B7=A6=E5=8F=B3=E7=9C=8B?= <1918891542@qq.com> Date: Thu, 29 Sep 2022 02:27:10 +0800 Subject: [PATCH 3/3] adjust shader loading for mod test --- Assets/Scripts/UmaViewerBuilder.cs | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/Assets/Scripts/UmaViewerBuilder.cs b/Assets/Scripts/UmaViewerBuilder.cs index 8488e7f..a7f359b 100644 --- a/Assets/Scripts/UmaViewerBuilder.cs +++ b/Assets/Scripts/UmaViewerBuilder.cs @@ -28,6 +28,12 @@ public class UmaViewerBuilder : MonoBehaviour public UmaHeadData CurrentHead; + public Shader hairShader; + public Shader faceShader; + public Shader eyeShader; + public Shader cheekShader; + public Shader eyebrowShader; + public List CurrentAudioSources = new List(); public List CurrentLyrics = new List(); @@ -605,8 +611,19 @@ public class UmaViewerBuilder : MonoBehaviour { if (bundle.name == "shader.a") { - if (Main.ShadersLoaded) return; - else Main.ShadersLoaded = true; + if (Main.ShadersLoaded) + { + return; + } + else + { + hairShader = (Shader)bundle.LoadAsset("assets/_gallop/resources/shader/3d/character/charactertoonhairtser.shader"); + faceShader = (Shader)bundle.LoadAsset("assets/_gallop/resources/shader/3d/character/charactertoonfacetser.shader"); + eyeShader = (Shader)bundle.LoadAsset("assets/_gallop/resources/shader/3d/character/charactertooneyet.shader"); + cheekShader = (Shader)bundle.LoadAsset("assets/_gallop/resources/shader/3d/character/charactermultiplycheek.shader"); + eyebrowShader = (Shader)bundle.LoadAsset("assets/_gallop/resources/shader/3d/character/charactertoonmayu.shader"); + Main.ShadersLoaded = true; + } } foreach (string name in bundle.GetAllAssetNames()) @@ -816,19 +833,25 @@ public class UmaViewerBuilder : MonoBehaviour switch (m.shader.name) { case "Gallop/3D/Chara/MultiplyCheek": + m.shader = cheekShader; m.CopyPropertiesFromMaterial(TransMaterialCharas); break; case "Gallop/3D/Chara/ToonFace/TSER": + m.shader = faceShader; m.SetFloat("_CylinderBlend", 0.25f); m.SetColor("_RimColor", new Color(0, 0, 0, 0)); break; case "Gallop/3D/Chara/ToonEye/T": + m.shader = eyeShader; m.SetFloat("_CylinderBlend", 0.25f); break; case "Gallop/3D/Chara/ToonHair/TSER": + m.shader = hairShader; m.SetFloat("_CylinderBlend", 0.25f); break; - + case "Gallop/3D/Chara/ToonMayu": + m.shader = eyebrowShader; + break; default: Debug.Log(m.shader.name); // m.shader = Shader.Find("Nars/UmaMusume/Body");