diff --git a/Assets/Plugins/RootMotion/FinalIK/_Integration/IK Jobs (Unity 2018.2.4f1).unitypackage.meta b/Assets/Plugins/RootMotion/FinalIK/_Integration/IK Jobs (Unity 2018.2.4f1).unitypackage.meta deleted file mode 100644 index fd115b1..0000000 --- a/Assets/Plugins/RootMotion/FinalIK/_Integration/IK Jobs (Unity 2018.2.4f1).unitypackage.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: b3e58808cb15120468eafdef64280407 -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/RootMotion/FinalIK/_Integration/IK Jobs (Unity 2019.3).unitypackage.meta b/Assets/Plugins/RootMotion/FinalIK/_Integration/IK Jobs (Unity 2019.3).unitypackage.meta deleted file mode 100644 index 00a91fc..0000000 --- a/Assets/Plugins/RootMotion/FinalIK/_Integration/IK Jobs (Unity 2019.3).unitypackage.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 59d63bcae2fecff42be7b4fc8b1df10f -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/RootMotion/FinalIK/_Integration/Oculus (Unity 2017.4.28f1, Oculus Integration v1.37).unitypackage.meta b/Assets/Plugins/RootMotion/FinalIK/_Integration/Oculus (Unity 2017.4.28f1, Oculus Integration v1.37).unitypackage.meta deleted file mode 100644 index d9fcdc9..0000000 --- a/Assets/Plugins/RootMotion/FinalIK/_Integration/Oculus (Unity 2017.4.28f1, Oculus Integration v1.37).unitypackage.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 7d1083877b3838042b9e91b249731b89 -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/RootMotion/FinalIK/_Integration/Playmaker (Unity 2017.4.28f1, PlayMaker 1.9.0).unitypackage.meta b/Assets/Plugins/RootMotion/FinalIK/_Integration/Playmaker (Unity 2017.4.28f1, PlayMaker 1.9.0).unitypackage.meta deleted file mode 100644 index 7ce27d6..0000000 --- a/Assets/Plugins/RootMotion/FinalIK/_Integration/Playmaker (Unity 2017.4.28f1, PlayMaker 1.9.0).unitypackage.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 0512c18ad5403428db876010796c1cda -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/RootMotion/FinalIK/_Integration/Steam VR (Unity 2017.4.28f1, SteamVR Plugin v2.2.0).unitypackage.meta b/Assets/Plugins/RootMotion/FinalIK/_Integration/Steam VR (Unity 2017.4.28f1, SteamVR Plugin v2.2.0).unitypackage.meta deleted file mode 100644 index 839abdf..0000000 --- a/Assets/Plugins/RootMotion/FinalIK/_Integration/Steam VR (Unity 2017.4.28f1, SteamVR Plugin v2.2.0).unitypackage.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 57ddc43ace113674392034825a54600a -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/RootMotion/FinalIK/_Integration/UMA (Unity 2017.4.28f1, UMA 2.8.1).unitypackage.meta b/Assets/Plugins/RootMotion/FinalIK/_Integration/UMA (Unity 2017.4.28f1, UMA 2.8.1).unitypackage.meta deleted file mode 100644 index 21cc026..0000000 --- a/Assets/Plugins/RootMotion/FinalIK/_Integration/UMA (Unity 2017.4.28f1, UMA 2.8.1).unitypackage.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: d00cc5f8e672c264d856aa10ed20df7e -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scenes/Version2.unity b/Assets/Scenes/Version2.unity index 4e44781..cfcc446 100644 --- a/Assets/Scenes/Version2.unity +++ b/Assets/Scenes/Version2.unity @@ -2166,7 +2166,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 0, y: -45.000305} + m_AnchoredPosition: {x: 0, y: -45.000244} m_SizeDelta: {x: 255, y: -90} m_Pivot: {x: 0, y: 0.5} --- !u!114 &92965282 @@ -6546,7 +6546,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 255, y: -45.000305} + m_AnchoredPosition: {x: 255, y: -45.000244} m_SizeDelta: {x: 270, y: -90} m_Pivot: {x: 0, y: 0.5} --- !u!114 &270183827 @@ -26296,7 +26296,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 380, y: -45.000305} + m_AnchoredPosition: {x: 380, y: -45.000244} m_SizeDelta: {x: 255, y: -90} m_Pivot: {x: 0, y: 0.5} --- !u!114 &931406427 @@ -26530,7 +26530,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 255, y: -45.000305} + m_AnchoredPosition: {x: 255, y: -45.000244} m_SizeDelta: {x: 270, y: -90} m_Pivot: {x: 0, y: 0.5} --- !u!114 &952551665 @@ -28784,7 +28784,7 @@ MonoBehaviour: maxAisacs: 8 maxBusSends: 8 maxSequenceEventsPerFrame: 2 - maxBeatSyncCallbacksPerFrame: 1 + maxBeatSyncCallbacksPerFrame: 8 maxCueLinkCallbacksPerFrame: 1 standardVoicePoolConfig: memoryVoices: 16 @@ -28905,7 +28905,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 0, y: -45.000305} + m_AnchoredPosition: {x: 0, y: -45.000244} m_SizeDelta: {x: 255, y: -90} m_Pivot: {x: 0, y: 0.5} --- !u!114 &1040294592 @@ -39372,7 +39372,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 1, y: 0} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: -29.999817} + m_AnchoredPosition: {x: 0, y: -29.999756} m_SizeDelta: {x: 300, y: -60.000233} m_Pivot: {x: 1, y: 0.5} --- !u!114 &1453791885 @@ -40708,7 +40708,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 0, y: -45.000305} + m_AnchoredPosition: {x: 0, y: -45.000244} m_SizeDelta: {x: 380, y: -90} m_Pivot: {x: 0, y: 0.5} --- !u!224 &1525688469 stripped @@ -41418,7 +41418,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 0, y: -45.000305} + m_AnchoredPosition: {x: 0, y: -45.000244} m_SizeDelta: {x: 255, y: -90} m_Pivot: {x: 0, y: 0.5} --- !u!114 &1558324558 @@ -44927,7 +44927,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 0, y: -45.000305} + m_AnchoredPosition: {x: 0, y: -45.000244} m_SizeDelta: {x: 380, y: -90} m_Pivot: {x: 0, y: 0.5} --- !u!114 &1678768231 @@ -45261,7 +45261,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 0, y: -45.000305} + m_AnchoredPosition: {x: 0, y: -45.000244} m_SizeDelta: {x: 380, y: -90} m_Pivot: {x: 0, y: 0.5} --- !u!222 &1684693616 @@ -45631,7 +45631,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 0, y: -45.000305} + m_AnchoredPosition: {x: 0, y: -45.000244} m_SizeDelta: {x: 380, y: -90} m_Pivot: {x: 0, y: 0.5} --- !u!114 &1699478760 @@ -47737,7 +47737,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 255, y: -45.000305} + m_AnchoredPosition: {x: 255, y: -45.000244} m_SizeDelta: {x: 270, y: -90} m_Pivot: {x: 0, y: 0.5} --- !u!114 &1765749874 @@ -52230,7 +52230,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 0, y: -45.000305} + m_AnchoredPosition: {x: 0, y: -45.000244} m_SizeDelta: {x: 400, y: -90} m_Pivot: {x: 0, y: 0.5} --- !u!114 &1970310175 @@ -57348,7 +57348,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 0, y: -45.000305} + m_AnchoredPosition: {x: 0, y: -45.000244} m_SizeDelta: {x: 400, y: -90} m_Pivot: {x: 0, y: 0.5} --- !u!114 &2129326814 @@ -58469,7 +58469,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 0, y: -45.000305} + m_AnchoredPosition: {x: 0, y: -45.000244} m_SizeDelta: {x: 255, y: -90} m_Pivot: {x: 0, y: 0.5} --- !u!114 &2146564492 diff --git a/Assets/Scripts/Audio/CRIMW/CriScript/LoadSound.cs b/Assets/Scripts/Audio/CRIMW/CriScript/LoadSound.cs deleted file mode 100644 index 30477f9..0000000 --- a/Assets/Scripts/Audio/CRIMW/CriScript/LoadSound.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using UnityEngine; - -public class LoadSound : ScriptableObject -{ - UmaViewerMain Main => UmaViewerMain.Instance; - public struct UmaSoundInfo - { - public string acbPath; - public string awbPath; - } - - - public UmaSoundInfo getSoundPath(string name) { - UmaSoundInfo info; - info.acbPath = Main.AbSounds.FirstOrDefault(a => a.Name.Contains(name) && a.Name.EndsWith("acb")).FilePath; - info.awbPath = Main.AbSounds.FirstOrDefault(a => a.Name.Contains(name) && a.Name.EndsWith("awb")).FilePath; - return info; - } - - -} diff --git a/Assets/Scripts/UmaDatabase/UmaDataTypes.cs b/Assets/Scripts/UmaDatabase/UmaDataTypes.cs index a7d4712..a337abf 100644 --- a/Assets/Scripts/UmaDatabase/UmaDataTypes.cs +++ b/Assets/Scripts/UmaDatabase/UmaDataTypes.cs @@ -4,6 +4,9 @@ using UnityEngine; using Gallop; using System.IO; using static UmaViewerUI; +using System.Xml.Linq; +using System.Windows.Markup; +using System; public class UmaDatabaseEntry { @@ -121,6 +124,32 @@ public class LiveEntry } } +public class PartEntry +{ + public Dictionary> PartSettings = new Dictionary>(); + + public PartEntry(string data) + { + string[] lines = data.Split("\n"[0]); + + string[] names = lines[0].Split(','); + + foreach (var name in names) + { + PartSettings[name] = new List(); + } + + for (int i = 1; i < lines.Length - 1; i++) + { + var values = lines[i].Split(','); + for (int j = 0; j < names.Length; j++) + { + PartSettings[names[j]].Add((float)Convert.ToDouble(values[j])); + } + } + } +} + [System.Serializable] public class CostumeEntry diff --git a/Assets/Scripts/UmaViewerAudio.cs b/Assets/Scripts/UmaViewerAudio.cs index a4b10b8..b6ed99c 100644 --- a/Assets/Scripts/UmaViewerAudio.cs +++ b/Assets/Scripts/UmaViewerAudio.cs @@ -3,83 +3,140 @@ using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; +using static CriWare.CriAtomExCategory.ReactDuckerParameter; public class UmaViewerAudio { - static public void LoadLiveSoundCri(int songid, UmaDatabaseEntry SongAwb) + + static UmaViewerMain Main => UmaViewerMain.Instance; + public struct UmaSoundInfo { - Debug.Log(SongAwb.Name); + public string acbPath; + public string awbPath; + } - //获取总线数 - Debug.Log(CriAtomExAcf.GetNumDspSettings()); + static public UmaSoundInfo getSoundPath(string name) + { + Debug.Log(name); + UmaSoundInfo info; + info.acbPath = Main.AbSounds.FirstOrDefault(a => a.Name.Contains(name) && a.Name.EndsWith("acb")).FilePath; + info.awbPath = Main.AbSounds.FirstOrDefault(a => a.Name.Contains(name) && a.Name.EndsWith("awb")).FilePath; + return info; + } - string busName = CriAtomExAcf.GetDspSettingNameByIndex(0); - - var dspSetInfo = new CriAtomExAcf.AcfDspSettingInfo(); - - - - Debug.Log(CriAtomExAcf.GetDspSettingInformation(busName, out dspSetInfo)); - - Debug.Log(dspSetInfo.name); - Debug.Log(dspSetInfo.numExtendBuses); - Debug.Log(dspSetInfo.numBuses); - Debug.Log(dspSetInfo.numSnapshots); - Debug.Log(dspSetInfo.snapshotStartIndex); - - var busInfo = new CriAtomExAcf.AcfDspBusInfo(); - - for (ushort i = 0; i < dspSetInfo.numExtendBuses; i++) - { - Debug.Log(i); - Debug.Log(CriAtomExAcf.GetDspBusInformation(i, out busInfo)); - - Debug.Log(busInfo.name); - Debug.Log(busInfo.volume); - Debug.Log(busInfo.numFxes); - Debug.Log(busInfo.numBusLinks); - } - - //获取Acb文件和Awb文件的路径 - string nameVar = SongAwb.Name.Split('.')[0].Split('/').Last(); - - //使用Live的Bgm - //nameVar = $"snd_bgm_live_{songid}_oke"; - - LoadSound Loader = (LoadSound)ScriptableObject.CreateInstance("LoadSound"); - LoadSound.UmaSoundInfo soundInfo = Loader.getSoundPath(nameVar); - - //音频组件添加路径,载入音频 - CriAtom.AddCueSheet(nameVar, soundInfo.acbPath, soundInfo.awbPath); - - //获得当前音频信息 - CriAtomEx.CueInfo[] cueInfoList; - List cueNameList = new List(); - cueInfoList = CriAtom.GetAcb(nameVar).GetCueInfoList(); - foreach (CriAtomEx.CueInfo cueInfo in cueInfoList) - { - cueNameList.Add(cueInfo.name); - Debug.Log(cueInfo.type); - Debug.Log(cueInfo.userData); - } + static public CriAtomSource ApplyCueSheet(string cueName) + { + UmaSoundInfo soundInfo = getSoundPath(cueName); + CriAtom.AddCueSheet(cueName, soundInfo.acbPath, soundInfo.awbPath); //创建播放器 CriAtomSource source = new GameObject("CuteAudioSource").AddComponent(); source.transform.SetParent(GameObject.Find("AudioManager/AudioControllerBgm").transform); - source.cueSheet = nameVar; + source.cueSheet = cueName; - //播放 - source.Play(cueNameList[0]); + source.use3dPositioning = false; - //source.SetBusSendLevelOffset(1, 1); + return source; + } + public enum PartForm + { + center = 0, + left = 1, + right = 2 + } - /* - for (int i = 0; i < 17; i++) + static public void AlterUpdate(float _liveCurrentTime, PartEntry partInfo, List liveVocal) + { + var timeLineData = partInfo.PartSettings["time"]; + var targetIndex = 0; + for (int i = timeLineData.Count - 1; i >= 0; i--) { - Debug.Log(source.player.GetParameterFloat32((CriAtomEx.Parameter)i)); + if (_liveCurrentTime >= (double)timeLineData[i] / 1000) + { + targetIndex = i; + break; + } } - */ + var volumeMixer = 0; + var useMixer = false; + + float _999_count = 0; + + for (int i = 0; i < liveVocal.Count; i++) + { + string partName = ((PartForm)i).ToString(); + + if (partInfo.PartSettings.ContainsKey(partName)){ + var value = partInfo.PartSettings[partName][targetIndex]; + + if (value == 0) + { + liveVocal[i].volume = 0; + volumeMixer += 1; + } + else + { + liveVocal[i].volume = 1; + liveVocal[i].player.SetSelectorLabel("BGM_Selector", $"SelectorLabel_{value-1}"); + } + + + float volume; + if (partInfo.PartSettings.ContainsKey(partName + "_vol")) + { + volume = partInfo.PartSettings[partName + "_vol"][targetIndex]; + if(volume != 999) + { + liveVocal[i].volume *= volume; + } + else + { + _999_count += 1; + } + } + } + } + + if (_999_count == liveVocal.Count) + { + useMixer = true; + } + + if (useMixer) + { + switch (volumeMixer) + { + case 0: + liveVocal[0].volume = 0.7056f; + liveVocal[1].volume = 0.56f; + liveVocal[2].volume = 0.56f; + break; + case 1: + for (int i = 0; i < liveVocal.Count; i++) + { + if (liveVocal[i].volume != 0) + { + liveVocal[i].volume = 0.7031f; + } + } + break; + case 2: + for (int i = 0; i < liveVocal.Count; i++) + { + if (liveVocal[i].volume != 0) + { + liveVocal[i].volume = 0.9954f; + } + } + break; + default: + liveVocal[0].volume = 0f; + liveVocal[1].volume = 0f; + liveVocal[2].volume = 0f; + break; + } + } } } diff --git a/Assets/Scripts/UmaViewerBuilder.cs b/Assets/Scripts/UmaViewerBuilder.cs index 9f69524..36ba084 100644 --- a/Assets/Scripts/UmaViewerBuilder.cs +++ b/Assets/Scripts/UmaViewerBuilder.cs @@ -18,7 +18,7 @@ using Random = UnityEngine.Random; public class UmaViewerBuilder : MonoBehaviour { public static UmaViewerBuilder Instance; - UmaViewerMain Main => UmaViewerMain.Instance; + public static UmaViewerMain Main => UmaViewerMain.Instance; UmaViewerUI UI => UmaViewerUI.Instance; public List Loaded; @@ -667,10 +667,13 @@ public class UmaViewerBuilder : MonoBehaviour GameObject Director = new GameObject("Director"); List transferObjs = new List() { MainLive, + GameObject.Find("CriWare"), + GameObject.Find("CriWareLibraryInitializer"), GameObject.Find("ViewerMain"), GameObject.Find("Camera"), GameObject.Find("Directional Light"), - GameObject.Find("AnimationCameraRoot") + GameObject.Find("AnimationCameraRoot"), + GameObject.Find("AudioManager") }; UmaSceneController.instance.LoadScene("LiveScene", @@ -700,7 +703,7 @@ public class UmaViewerBuilder : MonoBehaviour delegate () { Gallop.Live.Director.instance.InitializeTimeline(); - Gallop.Live.Director.instance.Play(live.MusicId, characters[0].CharaEntry.Id); + Gallop.Live.Director.instance.Play(live.MusicId, characters); } ); } @@ -708,7 +711,8 @@ public class UmaViewerBuilder : MonoBehaviour //Use CriWare Library - public void LoadLiveSoundCri(int songid, UmaDatabaseEntry SongAwb) + /* + public CriAtomSource LoadLiveSoundCri(int songid, UmaDatabaseEntry SongAwb) { //娓呯悊 if (CurrentAudioSources.Count > 0) @@ -722,6 +726,7 @@ public class UmaViewerBuilder : MonoBehaviour Debug.Log(SongAwb.Name); //鑾峰彇鎬荤嚎鏁� + Debug.Log(CriAtomExAcf.GetNumDspSettings()); string busName = CriAtomExAcf.GetDspSettingNameByIndex(0); @@ -782,17 +787,13 @@ public class UmaViewerBuilder : MonoBehaviour //鎾斁 source.Play(cueNameList[0]); + return source; + //source.SetBusSendLevelOffset(1, 1); - /* - for (int i = 0; i < 17; i++) - { - Debug.Log(source.player.GetParameterFloat32((CriAtomEx.Parameter)i)); - } - */ - } + */ //Use decrypt function public void LoadLiveSound(int songid, UmaDatabaseEntry SongAwb, bool needLyrics = true) @@ -941,7 +942,7 @@ public class UmaViewerBuilder : MonoBehaviour } } - public AssetBundle LoadOrGet(UmaDatabaseEntry entry) + public static AssetBundle LoadOrGet(UmaDatabaseEntry entry) { if ((Main.LoadedBundles.ContainsKey(entry.Name))) { diff --git a/Assets/Scripts/UmaViewerUI.cs b/Assets/Scripts/UmaViewerUI.cs index 92f4bbf..ec75c66 100644 --- a/Assets/Scripts/UmaViewerUI.cs +++ b/Assets/Scripts/UmaViewerUI.cs @@ -723,7 +723,7 @@ public class UmaViewerUI : MonoBehaviour HighlightChildImage(LiveCharaSoundList.content, container); if (isCriware) { - Builder.LoadLiveSoundCri(songid, entry); + //Builder.LoadLiveSoundCri(songid, entry); } else { diff --git a/Assets/Scripts/umamusume/Gallop/FaceDrivenKeyTarget.cs b/Assets/Scripts/umamusume/Gallop/FaceDrivenKeyTarget.cs index 636bd59..7379e8d 100644 --- a/Assets/Scripts/umamusume/Gallop/FaceDrivenKeyTarget.cs +++ b/Assets/Scripts/umamusume/Gallop/FaceDrivenKeyTarget.cs @@ -373,7 +373,7 @@ namespace Gallop { FacialResetMouth(); MouthMorphs.ForEach(morph => ProcessMorph(morph)); - ApplyRotationEye(); + ApplyRotationMouth(); } public void ClearMorph() @@ -504,7 +504,7 @@ namespace Gallop OverrideFace(Container.FaceOverrideData); } FacialReset(BaseMouthMorph.trsArray); - ApplyRotation(); + ApplyRotationMouth(); } public void FacialReset(List trsArrays) @@ -554,6 +554,19 @@ namespace Gallop applyRotation.Invoke(BaseREyeMorph.trsArray); } + public void ApplyRotationMouth() + { + Action> applyRotation = delegate (List trsArray) + { + foreach (TrsArray trs in trsArray) + { + if (trs.transform) + trs.transform.localRotation = RotationConvert.fromMaya(RotationRecorder[trs.transform]); + } + }; + applyRotation.Invoke(BaseMouthMorph.trsArray); + } + public void ChangeMorphWeight(FacialMorph morph, float val) { Container.isAnimatorControl = false; @@ -707,17 +720,17 @@ namespace Gallop return morphs.Find(m => m.index == (int)Type); } - private LiveTimelineKeyLipSyncData _prevKeyData; - private LiveTimelineKeyLipSyncData _lastKeyData; + private LiveTimelineKeyLipSyncData _prevLipKeyData; + private LiveTimelineKeyLipSyncData _lastLipKeyData; public void AlterUpdateAutoLip(LiveTimelineKeyLipSyncData keyData_, float liveTime_) { //Debug.Log((float)keyData_.frame); //Debug.Log(liveTime_); - if(_lastKeyData != keyData_) + if(_lastLipKeyData != keyData_) { - _prevKeyData = _lastKeyData; + _prevLipKeyData = _lastLipKeyData; } float keyTime = (float)keyData_.frame / 60; @@ -758,19 +771,19 @@ namespace Gallop MouthMorphs.ForEach(morph => morph.weight = 0); - if (_prevKeyData != null) + if (_prevLipKeyData != null) { if(weightRatio != 1) { - foreach (var part in _prevKeyData.facialPartsDataArray) + foreach (var part in _prevLipKeyData.facialPartsDataArray) { if (part.FacialPartsId == 0 ) { continue; } - MouthMorphs[part.FacialPartsId - 1].weight = ((float)part.WeightPer / 100 * (1 - weightRatio)) * ((float)_prevKeyData.weight / 100); + MouthMorphs[part.FacialPartsId - 1].weight = ((float)part.WeightPer / 100 * (1 - weightRatio)) * ((float)_prevLipKeyData.weight / 100); } } else { - foreach (var part in _prevKeyData.facialPartsDataArray) + foreach (var part in _prevLipKeyData.facialPartsDataArray) { if (part.FacialPartsId == 0) { continue; } MouthMorphs[part.FacialPartsId - 1].weight = 0; @@ -786,7 +799,124 @@ namespace Gallop ChangeMorphMouth(); - _lastKeyData = keyData_; + _lastLipKeyData = keyData_; + } + + private LiveTimelineKeyFacialEyeData _prevEyesKeyData; + private LiveTimelineKeyFacialEyeData _lastEyesKeyData; + + public void AlterUpdateFacialNew(ref FacialDataUpdateInfo updateInfo_, float liveTime_) + { + if(updateInfo_.eyeCur != null) + { + if (_lastEyesKeyData != updateInfo_.eyeCur) + { + _prevEyesKeyData = _lastEyesKeyData; + } + + float keyTime = (float)updateInfo_.eyeCur.frame / 60; + + + float duringTime; + if (updateInfo_.eyeNext != null) + { + duringTime = updateInfo_.eyeNext.frame - updateInfo_.eyeCur.frame; + } + else + { + duringTime = updateInfo_.eyeCur.time; + } + + float easeTime; + + if (duringTime < updateInfo_.eyeCur.time) + { + easeTime = (float)duringTime / 60; + } + else + { + easeTime = (float)updateInfo_.eyeCur.time / 60; + } + + + float passTime = liveTime_ - keyTime; + + float weightRatio = 0; + + if (passTime >= easeTime) + { + weightRatio = 1; + } + else + { + float ratio = passTime / easeTime; + switch (updateInfo_.eyeCur.interpolateType) + { + case InterpolateType.Linear: + weightRatio = ratio; + break; + case InterpolateType.EaseIn: + weightRatio = Easing.EaseIn(ratio); + break; + case InterpolateType.EaseOut: + weightRatio = Easing.EaseOut(ratio); + break; + case InterpolateType.EaseInOut: + weightRatio = Easing.EaseInOut(ratio); + break; + default: + weightRatio = ratio; + break; + } + } + + EyeMorphs.ForEach(morph => morph.weight = 0); + + if (_prevEyesKeyData != null) + { + if (weightRatio != 1) + { + foreach (var part in _prevEyesKeyData.facialPartsDataArrayL) + { + if (part.FacialPartsId == 0) { continue; } + leftEyeMorph[part.FacialPartsId - 1].weight = ((float)part.WeightPer / 100 * (1 - weightRatio)) * ((float)_prevEyesKeyData.weight / 100); + } + foreach (var part in _prevEyesKeyData.facialPartsDataArrayR) + { + if (part.FacialPartsId == 0) { continue; } + rightEyeMorph[part.FacialPartsId - 1].weight = ((float)part.WeightPer / 100 * (1 - weightRatio)) * ((float)_prevEyesKeyData.weight / 100); + } + } + else + { + foreach (var part in _prevEyesKeyData.facialPartsDataArrayL) + { + if (part.FacialPartsId == 0) { continue; } + leftEyeMorph[part.FacialPartsId - 1].weight = 0; + } + foreach (var part in _prevEyesKeyData.facialPartsDataArrayR) + { + if (part.FacialPartsId == 0) { continue; } + rightEyeMorph[part.FacialPartsId - 1].weight = 0; + } + } + } + + foreach (var part in updateInfo_.eyeCur.facialPartsDataArrayL) + { + if (part.FacialPartsId == 0) { continue; } + leftEyeMorph[part.FacialPartsId - 1].weight += ((float)part.WeightPer / 100 * weightRatio) * ((float)updateInfo_.eyeCur.weight / 100); + } + foreach (var part in updateInfo_.eyeCur.facialPartsDataArrayR) + { + if (part.FacialPartsId == 0) { continue; } + rightEyeMorph[part.FacialPartsId - 1].weight += ((float)part.WeightPer / 100 * weightRatio) * ((float)updateInfo_.eyeCur.weight / 100); + } + + ChangeMorphEye(); + + _lastEyesKeyData = updateInfo_.eyeCur; + } } } } diff --git a/Assets/Scripts/umamusume/Gallop/Live/Cutt/FacialDataUpdateInfo.cs b/Assets/Scripts/umamusume/Gallop/Live/Cutt/FacialDataUpdateInfo.cs new file mode 100644 index 0000000..bdd280b --- /dev/null +++ b/Assets/Scripts/umamusume/Gallop/Live/Cutt/FacialDataUpdateInfo.cs @@ -0,0 +1,27 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace Gallop.Live.Cutt +{ + public struct FacialDataUpdateInfo // TypeDefIndex: 29410 + { + // Fields + public LiveTimelineKeyFacialFaceData faceCur; // 0x0 + public LiveTimelineKeyFacialFaceData faceNext; // 0x8 + public LiveTimelineKeyFacialMouthData mouth; // 0x10 + public LiveTimelineKeyFacialEyeData eyeCur; // 0x18 + public LiveTimelineKeyFacialEyeData eyeNext; // 0x20 + public LiveTimelineKeyFacialEyebrowData eyebrow; // 0x28 + public LiveTimelineKeyFacialEyeTrackData eyeTrack; // 0x30 + public LiveTimelineKeyFacialEarData ear; // 0x38 + public LiveTimelineKeyFacialEffectData effect; // 0x40 + public int faceKeyIndex; // 0x48 + public int mouthKeyIndex; // 0x4C + public int eyeKeyIndex; // 0x50 + public int eyebrowKeyIndex; // 0x54 + public int eyeTrackKeyIndex; // 0x58 + public int earKeyIndex; // 0x5C + public int effectKeyIndex; // 0x60 + } +} diff --git a/Assets/Scripts/Audio/CRIMW/CriScript/LoadSound.cs.meta b/Assets/Scripts/umamusume/Gallop/Live/Cutt/FacialDataUpdateInfo.cs.meta similarity index 83% rename from Assets/Scripts/Audio/CRIMW/CriScript/LoadSound.cs.meta rename to Assets/Scripts/umamusume/Gallop/Live/Cutt/FacialDataUpdateInfo.cs.meta index b5de497..279ae0a 100644 --- a/Assets/Scripts/Audio/CRIMW/CriScript/LoadSound.cs.meta +++ b/Assets/Scripts/umamusume/Gallop/Live/Cutt/FacialDataUpdateInfo.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: ef2081963b0a68f4e8558e38b24cc264 +guid: d23729e48867d7143b85da3439885191 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Scripts/umamusume/Gallop/Live/Cutt/ILiveTimelineKeyDataList.cs b/Assets/Scripts/umamusume/Gallop/Live/Cutt/ILiveTimelineKeyDataList.cs index 84086ae..993ef2c 100644 --- a/Assets/Scripts/umamusume/Gallop/Live/Cutt/ILiveTimelineKeyDataList.cs +++ b/Assets/Scripts/umamusume/Gallop/Live/Cutt/ILiveTimelineKeyDataList.cs @@ -14,8 +14,10 @@ namespace Gallop.Live.Cutt //public abstract string Description { get; set; } //public abstract int depthCounter { get; } - LiveTimelineKey FindCurrentKey(float currentTime); + public abstract LiveTimelineKeyIndex TimeKeyIndex { get; } + LiveTimelineKeyIndex FindCurrentKey(float currentTime); + LiveTimelineKeyIndex UpdateCurrentKey(float currentTime); } } \ No newline at end of file diff --git a/Assets/Scripts/umamusume/Gallop/Live/Cutt/LiveTimelineControl.cs b/Assets/Scripts/umamusume/Gallop/Live/Cutt/LiveTimelineControl.cs index 306ea0f..94f41c8 100644 --- a/Assets/Scripts/umamusume/Gallop/Live/Cutt/LiveTimelineControl.cs +++ b/Assets/Scripts/umamusume/Gallop/Live/Cutt/LiveTimelineControl.cs @@ -27,6 +27,8 @@ namespace Gallop.Live.Cutt public event Action OnUpdateLipSync; + public event Action OnUpdateFacial; + public void CopyValues(T from, T to) { var json = JsonUtility.ToJson(from); @@ -93,6 +95,7 @@ namespace Gallop.Live.Cutt { AlterUpdate_CharaMotionSequence(liveTime); AlterUpdate_LipSync(liveTime); + AlterUpdate_FacialData(liveTime); } public void AlterUpdate_CharaMotionSequence(float liveTime) @@ -103,23 +106,68 @@ namespace Gallop.Live.Cutt } } + public void AlterUpdate_FacialData(float liveTime) + { + var facialDataList = data.worksheetList[0].facial1Set; + FacialDataUpdateInfo updateInfo = default(FacialDataUpdateInfo); + if (facialDataList != null) + { + SetupFacialUpdateInfo_Eye(ref updateInfo, facialDataList.eyeKeys, liveTime); + this.OnUpdateFacial(updateInfo, liveTime); + } + } + + private void SetupFacialUpdateInfo_Eye(ref FacialDataUpdateInfo updateInfo, LiveTimelineKeyFacialEyeDataList keys, float time) + { + LiveTimelineKey liveTimelineKey = null; + LiveTimelineKey liveTimelineKey2 = null; + + LiveTimelineKeyIndex curKey = AlterUpdate_Key(keys, time); + liveTimelineKey = curKey.key; + liveTimelineKey2 = curKey.nextKey; + updateInfo.eyeCur = liveTimelineKey as LiveTimelineKeyFacialEyeData; + updateInfo.eyeNext = liveTimelineKey2 as LiveTimelineKeyFacialEyeData; + updateInfo.eyeKeyIndex = curKey.index; + } + public void AlterUpdate_LipSync(float liveTime) { var lipDataList = data.worksheetList[0].ripSyncKeys; - LiveTimelineKey curKey = null; - FindTimelineKeyCurrent(out curKey, lipDataList, liveTime); - if (curKey != null) + LiveTimelineKeyIndex curKey = AlterUpdate_Key(lipDataList, liveTime); + + if (curKey != null && curKey.index != -1) { - LiveTimelineKeyLipSyncData arg = curKey as LiveTimelineKeyLipSyncData; + LiveTimelineKeyLipSyncData arg = curKey.key as LiveTimelineKeyLipSyncData; this.OnUpdateLipSync(arg, liveTime); } } - public void FindTimelineKeyCurrent(out LiveTimelineKey curKey, ILiveTimelineKeyDataList keys, float curTime) + public static void FindTimelineKeyCurrent(out LiveTimelineKeyIndex curKey, ILiveTimelineKeyDataList keys, float curTime) { curKey = keys.FindCurrentKey(curTime); } + + public static void UpdateTimelineKeyCurrent(out LiveTimelineKeyIndex curKey, ILiveTimelineKeyDataList keys, float curTime) + { + curKey = keys.UpdateCurrentKey(curTime); + } + + public static LiveTimelineKeyIndex AlterUpdate_Key(ILiveTimelineKeyDataList keys, float curTime) + { + LiveTimelineKeyIndex curKey = keys.TimeKeyIndex; + + if (curKey.index == -1) + { + FindTimelineKeyCurrent(out curKey, keys, curTime); + } + else + { + UpdateTimelineKeyCurrent(out curKey, keys, curTime); + } + + return curKey; + } } diff --git a/Assets/Scripts/umamusume/Gallop/Live/Cutt/LiveTimelineMotionSequence.cs b/Assets/Scripts/umamusume/Gallop/Live/Cutt/LiveTimelineMotionSequence.cs index 154fe3e..1f148f0 100644 --- a/Assets/Scripts/umamusume/Gallop/Live/Cutt/LiveTimelineMotionSequence.cs +++ b/Assets/Scripts/umamusume/Gallop/Live/Cutt/LiveTimelineMotionSequence.cs @@ -58,61 +58,20 @@ namespace Gallop.Live.Cutt { if (_currentKey != null && _tempAnim != null) { - /* - var seqs = _currentKey.thisList; + LiveTimelineKeyIndex curKey = LiveTimelineControl.AlterUpdate_Key(_currentKey, currentTime); - for (int i = seqs.Count - 1; i >= 0; i--) + if (curKey != null && curKey.index != -1) { - Debug.Log(currentTime); - if (currentTime >= (double)seqs[i].frame / 60) - { - Debug.Log("时间:" + ((double)seqs[i].frame / 60).ToString()); + LiveTimelineKeyCharaMotionData arg = curKey.key as LiveTimelineKeyCharaMotionData; - AnimationClip anim = seqs[i].clip; - double start = (double)seqs[i].motionHeadFrame / 60; - double interval = currentTime - (double)seqs[i].frame / 60; - - Debug.Log("time:" + interval.ToString()); - - //anim.SampleAnimation(container.gameObject, (float)(start + interval)); - _tempAnim[anim.name].time = (float)(start + interval); - _tempAnim.Play(anim.name); - - break; - } - } - */ - - var timelineKey = GetKey(currentTime); - - //if ( _prevKey != timelineKey ) Play animation all the time not affect performance maybe? - if ( true ) - { - AnimationClip anim = timelineKey.clip; - double start = (double)timelineKey.motionHeadFrame / 60; - double interval = currentTime - (double)timelineKey.frame / 60; + AnimationClip anim = arg.clip; + double start = (double)arg.motionHeadFrame / 60; + double interval = currentTime - (double)arg.frame / 60; _tempAnim[anim.name].time = (float)(start + interval); _tempAnim.Play(anim.name); - - _prevKey = timelineKey; } } } - - public LiveTimelineKeyCharaMotionData GetKey(float time) - { - var seqs = _currentKey.thisList; - - for (int i = seqs.Count - 1; i >= 0; i--) - { - if (time >= (double)seqs[i].frame / 60) - { - return seqs[i]; - } - } - - return seqs[0]; - } } } diff --git a/Assets/Scripts/umamusume/Gallop/Live/Cutt/LiveTimelineWorkSheet.cs b/Assets/Scripts/umamusume/Gallop/Live/Cutt/LiveTimelineWorkSheet.cs index 526e6ea..f02c8d4 100644 --- a/Assets/Scripts/umamusume/Gallop/Live/Cutt/LiveTimelineWorkSheet.cs +++ b/Assets/Scripts/umamusume/Gallop/Live/Cutt/LiveTimelineWorkSheet.cs @@ -126,7 +126,12 @@ namespace Gallop.Live.Cutt private TimelineKeyPlayMode _playMode; public List thisList; + + public LiveTimelineKeyIndex thisTimeKeyIndex = new LiveTimelineKeyIndex(); + public int Count => thisList.Count; + public LiveTimelineKeyIndex TimeKeyIndex => thisTimeKeyIndex; + public LiveTimelineKey this[int index] { @@ -140,20 +145,61 @@ namespace Gallop.Live.Cutt } } - public LiveTimelineKey FindCurrentKey(float currentTime) + public LiveTimelineKeyIndex FindCurrentKey(float currentTime) { for (int i = thisList.Count - 1; i >= 0; i--) { if (currentTime >= (double)thisList[i].frame / 60) { - return thisList[i]; + thisTimeKeyIndex.index = i; + thisTimeKeyIndex.key = thisList[i]; + if(i+1 != thisList.Count) + { + thisTimeKeyIndex.nextKey = thisList[i + 1]; + } + else + { + thisTimeKeyIndex.nextKey = null; + } + return thisTimeKeyIndex; } } return null; + } + + public LiveTimelineKeyIndex UpdateCurrentKey(float currentTime) + { + if (thisTimeKeyIndex.nextKey != null) + { + if (currentTime >= (double)thisTimeKeyIndex.nextKey.frame / 60) + { + thisTimeKeyIndex.index++; + thisTimeKeyIndex.key = thisList[thisTimeKeyIndex.index]; + if (thisTimeKeyIndex.index + 1 != thisList.Count) + { + thisTimeKeyIndex.nextKey = thisList[thisTimeKeyIndex.index + 1]; + } + else + { + thisTimeKeyIndex.nextKey = null; + } + } + } + + return thisTimeKeyIndex; + } } - [System.Serializable] + [System.Serializable] + public class LiveTimelineKeyIndex + { + public int index = -1; + public LiveTimelineKey key = null; + public LiveTimelineKey nextKey = null; + } + + [System.Serializable] public abstract class LiveTimelineKey { public int frame; diff --git a/Assets/Scripts/umamusume/Gallop/Live/Director.cs b/Assets/Scripts/umamusume/Gallop/Live/Director.cs index 8d43908..5e8d51a 100644 --- a/Assets/Scripts/umamusume/Gallop/Live/Director.cs +++ b/Assets/Scripts/umamusume/Gallop/Live/Director.cs @@ -11,6 +11,7 @@ using UnityEditor.SceneManagement; using static UnityEditor.Experimental.AssetDatabaseExperimental.AssetDatabaseCounters; using System.Data; using System.Runtime.Remoting.Metadata.W3cXsd2001; +using CriWare; namespace Gallop.Live { @@ -312,9 +313,10 @@ namespace Gallop.Live public LiveEntry live; private const string CUTT_PATH = "cutt/cutt_son{0}/cutt_son{0}"; private const string STAGE_PATH = "3d/env/live/live{0}/pfb_env_live{0}_controller000"; - private const string SONG_PATH = "sound/l/{0}/snd_bgm_live_{0}_oke_01.awb"; - private const string VOCAL_PATH = "sound/l/{0}/snd_bgm_live_{0}_chara_{1}_01.awb"; + private const string SONG_PATH = "sound/l/{0}/snd_bgm_live_{0}_oke_01"; + private const string VOCAL_PATH = "sound/l/{0}/snd_bgm_live_{0}_chara_{1}_01"; private const string RANDOM_VOCAL_PATH = "sound/l/{0}/snd_bgm_live_{0}_chara"; + private const string LIVE_PART_PATH = "live/musicscores/m{0}/m{0}_part"; private UmaViewerBuilder Builder => UmaViewerBuilder.Instance; @@ -328,6 +330,14 @@ namespace Gallop.Live public AudioSource liveSong; + public List liveVocal; + public CriAtomSource liveMusic; + + public PartEntry partInfo; + + public bool _syncTime = false; + public bool _soloMode = true; + private void Awake() { if (live != null) @@ -336,7 +346,7 @@ namespace Gallop.Live Debug.Log(string.Format(CUTT_PATH, live.MusicId)); Debug.Log(live.BackGroundId); Builder.LoadAssetPath(string.Format(CUTT_PATH, live.MusicId), this.gameObject.transform); - Builder.LoadAssetPath(string.Format(STAGE_PATH, live.BackGroundId), this.gameObject.transform); + //Builder.LoadAssetPath(string.Format(STAGE_PATH, live.BackGroundId), this.gameObject.transform); //Make CharacterObject @@ -352,13 +362,16 @@ namespace Gallop.Live charaObjs.Add(newObj.transform); counter++; }; - - //Set Animation - + //Get live parts info + UmaDatabaseEntry partAsset = UmaViewerMain.Instance.AbList.FirstOrDefault(a => a.Name.Contains(string.Format(LIVE_PART_PATH, live.MusicId))); + + Debug.Log(partAsset.Name); + + AssetBundle bundle = UmaViewerBuilder.LoadOrGet(partAsset); + TextAsset partData = bundle.LoadAsset($"m{live.MusicId}_part"); + partInfo = new PartEntry(partData.text); - - } } @@ -368,18 +381,6 @@ namespace Gallop.Live _liveTimelineControl.OnUpdateLipSync += delegate (LiveTimelineKeyLipSyncData keyData_, float liveTime_) { - /* - for (int k = 0; k < MemberUnitNumber; k++) - { - int num4 = k % MemberUnitNumber; - if (_characterObjects[num4].isSetting) - { - _characterObjects[num4].faceController.AlterUpdateAutoLip(liveTime_, keyData_, (LiveCharaPosition)num4); - } - } - */ - - for (int k = 0; k < charaObjs.Count; k++) { var container = charaObjs[k].GetComponentInChildren(); @@ -388,43 +389,81 @@ namespace Gallop.Live container.FaceDrivenKeyTarget.AlterUpdateAutoLip(keyData_, liveTime_); } } - - /* + }; + _liveTimelineControl.OnUpdateFacial += delegate (FacialDataUpdateInfo updateInfo_, float liveTime_) + { var container = charaObjs[0].GetComponentInChildren(); - if (container != null) - { - container.FaceDrivenKeyTarget.AlterUpdateAutoLip(keyData_, liveTime_); - } - */ + container.FaceDrivenKeyTarget.AlterUpdateFacialNew(ref updateInfo_, liveTime_); }; } - public void Play(int songid, int charaid) + public void Play(int songid, List characters) { Debug.Log(songid); - Debug.Log(charaid); - Debug.Log(string.Format(VOCAL_PATH, songid, charaid)); - var entry = UmaViewerMain.Instance.AbSounds.FirstOrDefault(a => a.Name.Contains(string.Format(VOCAL_PATH, songid, charaid))); - if (entry == null) + + if (!_soloMode) { - List entries = new List(); - foreach (var random in UmaViewerMain.Instance.AbSounds.Where(a => (a.Name.Contains(string.Format(RANDOM_VOCAL_PATH, songid)) && a.Name.EndsWith("awb")))) + for (int i = 0; i < characters.Count; i++) { - entries.Add(random); - } - if (entries.Count > 0) - { - entry = entries[UnityEngine.Random.Range(0, entries.Count - 1)]; - } - } - if(entry != null) - { - Debug.Log(entry.Name); - } + if (characters[i].CharaEntry.Name != "" && i < 3) + { + var charaid = characters[i].CharaEntry.Id; - UmaViewerBuilder.Instance.LoadLiveSound(songid, entry, false); - liveSong = GameObject.Find("SoundController").GetComponent(); + var entry = UmaViewerMain.Instance.AbSounds.FirstOrDefault(a => a.Name.Contains(string.Format(VOCAL_PATH, songid, charaid)) && a.Name.EndsWith("awb")); + if (entry == null) + { + List entries = new List(); + foreach (var random in UmaViewerMain.Instance.AbSounds.Where(a => (a.Name.Contains(string.Format(RANDOM_VOCAL_PATH, songid)) && a.Name.EndsWith("awb")))) + { + entries.Add(random); + } + if (entries.Count > 0) + { + entry = entries[UnityEngine.Random.Range(0, entries.Count - 1)]; + } + } + + if (entry != null) + { + Debug.Log(entry.Name); + liveVocal.Add(UmaViewerAudio.ApplyCueSheet(entry.Name.Split('.')[0])); + } + } + } + + + liveMusic = UmaViewerAudio.ApplyCueSheet(string.Format(SONG_PATH, songid)); + + foreach (var vocal in liveVocal) + { + vocal.Play(0); + } + liveMusic.Play(0); + } + else + { + var entry = UmaViewerMain.Instance.AbSounds.FirstOrDefault(a => a.Name.Contains(string.Format(VOCAL_PATH, songid, characters[0].CharaEntry.Id)) && a.Name.EndsWith("awb")); + if (entry == null) + { + List entries = new List(); + foreach (var random in UmaViewerMain.Instance.AbSounds.Where(a => (a.Name.Contains(string.Format(RANDOM_VOCAL_PATH, songid)) && a.Name.EndsWith("awb")))) + { + entries.Add(random); + } + if (entries.Count > 0) + { + entry = entries[UnityEngine.Random.Range(0, entries.Count - 1)]; + } + } + if (entry != null) + { + Debug.Log(entry.Name); + } + + UmaViewerBuilder.Instance.LoadLiveSound(songid, entry, false); + liveSong = GameObject.Find("SoundController").GetComponent(); + } _isLiveSetup = true; _liveCurrentTime = 0; @@ -433,18 +472,40 @@ namespace Gallop.Live private void OnTimelineUpdate(float _liveCurrentTime) { _liveTimelineControl.AlterUpdate(_liveCurrentTime); + if (!_soloMode) + { + UmaViewerAudio.AlterUpdate(_liveCurrentTime, partInfo, liveVocal); + } } void Update() { if (_isLiveSetup) { - _liveCurrentTime += Time.deltaTime; - OnTimelineUpdate(_liveCurrentTime); - } - else - { - _liveCurrentTime = 0; + if(_syncTime == false) + { + if (!_soloMode) + { + if(liveMusic.time > 0) + { + _liveCurrentTime = liveMusic.time / 1000; + _syncTime = true; + } + } + else + { + if(liveSong.time > 0) + { + _liveCurrentTime = liveSong.time; + _syncTime = true; + } + } + } + else + { + _liveCurrentTime += Time.deltaTime; + OnTimelineUpdate(_liveCurrentTime); + } } } } diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt index 3598ae5..495468b 100644 --- a/ProjectSettings/ProjectVersion.txt +++ b/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 2020.3.28f1 -m_EditorVersionWithRevision: 2020.3.28f1 (f5400f52e03f) +m_EditorVersion: 2020.3.24f1 +m_EditorVersionWithRevision: 2020.3.24f1 (79c78de19888)