From a935d2aec10c7b43a5e3a8776d385c5194d9cbbd Mon Sep 17 00:00:00 2001 From: gamer-jp <64856190+gamer-jp@users.noreply.github.com> Date: Thu, 29 Sep 2022 01:21:16 +0900 Subject: [PATCH 1/3] Animation progress text change to FrameCount format. --- Assets/Scripts/UmaViewerUI.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Assets/Scripts/UmaViewerUI.cs b/Assets/Scripts/UmaViewerUI.cs index a7cec14..c4c5e1b 100644 --- a/Assets/Scripts/UmaViewerUI.cs +++ b/Assets/Scripts/UmaViewerUI.cs @@ -584,7 +584,7 @@ public class UmaViewerUI : MonoBehaviour Builder.CurrentUMAContainer.UmaAnimator.speed = 0; animator.Play(0, -1, val); - AnimationProgressText.text = string.Format("{0} / {1}", ToTimeFormat(val * AnimeClip.length), ToTimeFormat(AnimeClip.length)); + AnimationProgressText.text = string.Format("{0} / {1}", ToFrameFormat(val * AnimeClip.length, AnimeClip.frameRate), ToFrameFormat(AnimeClip.length, AnimeClip.frameRate)); } } @@ -619,8 +619,9 @@ public class UmaViewerUI : MonoBehaviour if (AnimeClip && Builder.CurrentUMAContainer.UmaAnimator.speed != 0) { AnimationTitleText.text = AnimeClip.name; - AnimationProgressText.text = string.Format("{0} / {1}", ToTimeFormat(AnimeState.normalizedTime * AnimeClip.length), ToTimeFormat(AnimeClip.length)); - AnimationSlider.SetValueWithoutNotify(AnimeState.normalizedTime); + var normalizedTime = (AnimeState.normalizedTime < 1.0f) ? AnimeState.normalizedTime : 1.0f; + AnimationProgressText.text = string.Format("{0} / {1}", ToFrameFormat(normalizedTime * AnimeClip.length, AnimeClip.frameRate), ToFrameFormat(AnimeClip.length, AnimeClip.frameRate)); + AnimationSlider.SetValueWithoutNotify(normalizedTime); } } } @@ -643,6 +644,15 @@ public class UmaViewerUI : MonoBehaviour return string.Format("{0:D2}:{1:D2}:{2:D2}", hour, minute, seconds); } + public static string ToFrameFormat(float time, float frameRate) + { + int frames = Mathf.FloorToInt(time % 1 * frameRate); + int seconds = (int)time; + int minute = seconds % 3600 / 60; + seconds = seconds % 3600 % 60; + return string.Format("{0:D2}m:{1:D2}s:{2:D2}f", minute, seconds, frames); + } + public string GetCurrentLyrics(float time) { for(int i = Builder.CurrentLyrics.Count-1; i >=0; i--) 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 2/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"); From 590568cb109466872e1dd3a5d04b2a68561db75f Mon Sep 17 00:00:00 2001 From: gamer-jp <64856190+gamer-jp@users.noreply.github.com> Date: Thu, 29 Sep 2022 04:26:15 +0900 Subject: [PATCH 3/3] loop support --- Assets/Scripts/UmaViewerUI.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/UmaViewerUI.cs b/Assets/Scripts/UmaViewerUI.cs index ac9414d..b2e227b 100644 --- a/Assets/Scripts/UmaViewerUI.cs +++ b/Assets/Scripts/UmaViewerUI.cs @@ -580,6 +580,8 @@ public class UmaViewerUI : MonoBehaviour if (animator != null) { var AnimeClip = Builder.CurrentUMAContainer.OverrideController["clip_2"]; + + // Pause and Seek; Builder.CurrentUMAContainer.UmaAnimator.speed = 0; animator.Play(0, -1, val); @@ -613,13 +615,16 @@ public class UmaViewerUI : MonoBehaviour { if(Builder.CurrentUMAContainer.OverrideController["clip_2"].name != "clip_2") { + bool isLoop = Builder.CurrentUMAContainer.OverrideController["clip_2"].name.EndsWith("_loop"); var AnimeState = Builder.CurrentUMAContainer.UmaAnimator.GetCurrentAnimatorStateInfo(0); var AnimeClip = Builder.CurrentUMAContainer.OverrideController["clip_2"]; if (AnimeClip && Builder.CurrentUMAContainer.UmaAnimator.speed != 0) { + var normalizedTime = (isLoop) ? Mathf.Repeat(AnimeState.normalizedTime, 1) : Mathf.Min(AnimeState.normalizedTime, 1); + AnimationTitleText.text = AnimeClip.name; - AnimationProgressText.text = string.Format("{0} / {1}", ToFrameFormat(Mathf.Repeat(AnimeState.normalizedTime, 1) * AnimeClip.length, AnimeClip.frameRate), ToFrameFormat(AnimeClip.length, AnimeClip.frameRate)); - AnimationSlider.SetValueWithoutNotify(Mathf.Repeat(AnimeState.normalizedTime, 1)); + AnimationProgressText.text = string.Format("{0} / {1}", ToFrameFormat(normalizedTime * AnimeClip.length, AnimeClip.frameRate), ToFrameFormat(AnimeClip.length, AnimeClip.frameRate)); + AnimationSlider.SetValueWithoutNotify(normalizedTime); } } }