diff --git a/Assets/Scripts/UmaViewerBuilder.cs b/Assets/Scripts/UmaViewerBuilder.cs index 1d97be0..a8766a9 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(); @@ -606,8 +612,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()) @@ -817,19 +834,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"); diff --git a/Assets/Scripts/UmaViewerUI.cs b/Assets/Scripts/UmaViewerUI.cs index ba95e59..b2e227b 100644 --- a/Assets/Scripts/UmaViewerUI.cs +++ b/Assets/Scripts/UmaViewerUI.cs @@ -580,10 +580,12 @@ 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); - 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)); } } @@ -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}", ToTimeFormat(Mathf.Repeat(AnimeState.normalizedTime, 1) * AnimeClip.length), ToTimeFormat(AnimeClip.length)); - 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); } } } @@ -643,6 +648,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--)