A demo for using CriWare plugin.

This commit is contained in:
左右看
2022-09-09 22:47:10 +08:00
parent 6169e23829
commit c94407530d
7 changed files with 102 additions and 12 deletions
@@ -0,0 +1,24 @@
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 = UmaViewerBuilder.GetABPath(Main.AbList.FirstOrDefault(a => a.Name.Contains(name) && a.Name.EndsWith("acb")));
info.awbPath = UmaViewerBuilder.GetABPath(Main.AbList.FirstOrDefault(a => a.Name.Contains(name) && a.Name.EndsWith("awb")));
return info;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ef2081963b0a68f4e8558e38b24cc264
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+43 -6
View File
@@ -1,4 +1,5 @@
using CriWareFormats;
using CriWare;
using CriWareFormats;
using Gallop;
using NAudio.Wave;
using NAudio.Wave.SampleProviders;
@@ -30,8 +31,6 @@ public class UmaViewerBuilder : MonoBehaviour
public List<AudioSource> CurrentAudioSources = new List<AudioSource>();
public List<UmaLyricsData> CurrentLyrics = new List<UmaLyricsData>();
public bool isCirware = false;
public AnimatorOverrideController OverrideController;
@@ -358,11 +357,49 @@ public class UmaViewerBuilder : MonoBehaviour
}
public void SetCriWare(bool value)
//Use CriWare Library
public void LoadLiveSoundCri(int songid, UmaDatabaseEntry SongAwb)
{
isCirware = value;
//清理
if (CurrentAudioSources.Count > 0)
{
var tmp = CurrentAudioSources[0];
CurrentAudioSources.Clear();
Destroy(tmp.gameObject);
UI.ResetAudioPlayer();
}
//获取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<string> cueNameList = new List<string>();
cueInfoList = CriAtom.GetAcb(nameVar).GetCueInfoList();
foreach (CriAtomEx.CueInfo cueInfo in cueInfoList)
{
cueNameList.Add(cueInfo.name);
}
//创建播放器
CriAtomSource source = new GameObject("CuteAudioSource").AddComponent<CriAtomSource>();
source.transform.SetParent(GameObject.Find("AudioManager/AudioControllerBgm").transform);
source.cueSheet = nameVar;
//播放
source.Play(cueNameList[0]);
}
//Use decrypt function
public void LoadLiveSound(int songid, UmaDatabaseEntry SongAwb)
{
if (CurrentAudioSources.Count > 0)
@@ -822,7 +859,7 @@ public class UmaViewerBuilder : MonoBehaviour
UI.LoadedAssetsClear();
}
private static string GetABPath(UmaDatabaseEntry entry)
public static string GetABPath(UmaDatabaseEntry entry)
{
return $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "Low"}\\Cygames\\umamusume\\dat\\{entry.Url.Substring(0, 2)}\\{entry.Url}";
}
+1
View File
@@ -57,6 +57,7 @@ public class UmaViewerGlobalShader : MonoBehaviour
void setGlobal()
{
//Color
Shader.SetGlobalColor("_GlobalToonColor", _GlobalToonColor);
Shader.SetGlobalColor("_Global_FogColor", _Global_FogColor);
+16 -1
View File
@@ -55,6 +55,8 @@ public class UmaViewerUI : MonoBehaviour,FaceLoadCallBack
public Color UIColor1, UIColor2;
public bool isCirware = false;
private void Awake()
{
Instance = this;
@@ -268,6 +270,12 @@ public class UmaViewerUI : MonoBehaviour,FaceLoadCallBack
}
}
public void SetCriWare(bool value)
{
isCirware = value;
}
void ListLiveSounds(int songid)
{
for (int i = LiveCharaSoundList.content.childCount - 1; i >= 0; i--)
@@ -283,7 +291,14 @@ public class UmaViewerUI : MonoBehaviour,FaceLoadCallBack
container.Name.text = name;
container.Button.onClick.AddListener(() => {
HighlightChildImage(LiveCharaSoundList.content, container.GetComponent<Image>());
Builder.LoadLiveSound(songid, entry);
if (isCirware)
{
Builder.LoadLiveSoundCri(songid, entry);
}
else
{
Builder.LoadLiveSound(songid, entry);
}
});
}
+2 -1
View File
@@ -2,7 +2,8 @@
"name": "umamusume",
"rootNamespace": "",
"references": [
"GUID:6055be8ebefd69e48b49212b09b47b2f"
"GUID:6055be8ebefd69e48b49212b09b47b2f",
"GUID:800597811bcc5d848b15e12807d6de45"
],
"includePlatforms": [],
"excludePlatforms": [],