This commit is contained in:
CroakFang
2023-07-10 02:04:46 +08:00
11 changed files with 1348 additions and 58 deletions
File diff suppressed because it is too large Load Diff
+3 -2
View File
@@ -13,7 +13,7 @@ public class UmaSceneController:MonoBehaviour
{ {
if (instance) if (instance)
{ {
Destroy(this.gameObject); Destroy(instance.gameObject);
} }
instance = this; instance = this;
DontDestroyOnLoad(this); DontDestroyOnLoad(this);
@@ -26,9 +26,10 @@ public class UmaSceneController:MonoBehaviour
IEnumerator LoadLiveSceneAsync(string sceneName, Action OnSceneloaded, Action OnLastSceneUnloaded) IEnumerator LoadLiveSceneAsync(string sceneName, Action OnSceneloaded, Action OnLastSceneUnloaded)
{ {
if (CavansInstance) if (CavansInstance)
{ {
Destroy(CavansInstance); //Destroy(CavansInstance);
} }
CavansInstance = Instantiate(CavansPrefab, transform); CavansInstance = Instantiate(CavansPrefab, transform);
var animation = CavansInstance.GetComponent<Animation>(); var animation = CavansInstance.GetComponent<Animation>();
+8 -2
View File
@@ -66,6 +66,8 @@ public class UmaViewerAudio
float _999_count = 0; float _999_count = 0;
bool _no999 = false;
for (int i = 0; i < liveVocal.Count; i++) for (int i = 0; i < liveVocal.Count; i++)
{ {
string partName = ((PartForm)i).ToString(); string partName = ((PartForm)i).ToString();
@@ -97,11 +99,15 @@ public class UmaViewerAudio
{ {
_999_count += 1; _999_count += 1;
} }
} }
else
{
_no999 = true;
}
} }
} }
if (_999_count == liveVocal.Count) if ((_999_count == liveVocal.Count && liveVocal.Count != 0) || _no999)
{ {
useMixer = true; useMixer = true;
} }
+16 -5
View File
@@ -90,10 +90,21 @@ public class UmaViewerBuilder : MonoBehaviour
if (characters[i].CharaEntry.Name != "") if (characters[i].CharaEntry.Name != "")
{ {
CurrentUMAContainer = new GameObject($"Chara_{characters[i].CharaEntry.Id}_{characters[i].CostumeId}").AddComponent<UmaContainer>(); CurrentUMAContainer = new GameObject($"Chara_{characters[i].CharaEntry.Id}_{characters[i].CostumeId}").AddComponent<UmaContainer>();
CurrentUMAContainer.IsLive = true;
CurrentUMAContainer.CharaData = UmaDatabaseController.ReadCharaData(characters[i].CharaEntry); if (characters[i].CharaEntry.IsMob)
CurrentUMAContainer.transform.parent = Gallop.Live.Director.instance.charaObjs[i]; {
LoadNormalUma(characters[i].CharaEntry, characters[i].CostumeId); CurrentUMAContainer.IsLive = true;
CurrentUMAContainer.CharaData = UmaDatabaseController.ReadCharaData(characters[i].CharaEntry);
CurrentUMAContainer.transform.parent = Gallop.Live.Director.instance.charaObjs[i];
LoadMobUma(characters[i].CharaEntry, characters[i].CostumeId);
}
else
{
CurrentUMAContainer.IsLive = true;
CurrentUMAContainer.CharaData = UmaDatabaseController.ReadCharaData(characters[i].CharaEntry);
CurrentUMAContainer.transform.parent = Gallop.Live.Director.instance.charaObjs[i];
LoadNormalUma(characters[i].CharaEntry, characters[i].CostumeId);
}
} }
} }
} }
@@ -697,7 +708,7 @@ public class UmaViewerBuilder : MonoBehaviour
}, },
delegate () delegate ()
{ {
Gallop.Live.Director.instance.InitializeTimeline(characters.Count); Gallop.Live.Director.instance.InitializeTimeline(characters, UI.LiveMode);
Gallop.Live.Director.instance.Play(live.MusicId, characters); Gallop.Live.Director.instance.Play(live.MusicId, characters);
} }
); );
+1 -1
View File
@@ -149,7 +149,7 @@ public class UmaViewerMain : MonoBehaviour
string filePath = asset.FilePath; string filePath = asset.FilePath;
if (File.Exists(filePath)) if (File.Exists(filePath))
{ {
AssetBundle bundle = AssetBundle.LoadFromFile(filePath); AssetBundle bundle = UmaViewerBuilder.LoadOrGet(asset);
foreach (var item in UmaDatabaseController.Instance.LiveData) foreach (var item in UmaDatabaseController.Instance.LiveData)
{ {
var musicId = Convert.ToInt32(item["music_id"]); var musicId = Convert.ToInt32(item["music_id"]);
+106 -12
View File
@@ -10,6 +10,7 @@ using TMPro;
using UnityEngine; using UnityEngine;
using UnityEngine.Events; using UnityEngine.Events;
using UnityEngine.UI; using UnityEngine.UI;
using static UnityEditor.SceneView;
using Debug = UnityEngine.Debug; using Debug = UnityEngine.Debug;
public class UmaViewerUI : MonoBehaviour public class UmaViewerUI : MonoBehaviour
@@ -134,7 +135,10 @@ public class UmaViewerUI : MonoBehaviour
public bool EnableEyeTracking = true; public bool EnableEyeTracking = true;
public bool EnableFaceOverride = true; public bool EnableFaceOverride = true;
[Header("Live")]
public bool LiveTime = false; public bool LiveTime = false;
public Dropdown LiveDropdown;
public int LiveMode = 0;
public FaceDrivenKeyTarget currentFaceDrivenKeyTarget; public FaceDrivenKeyTarget currentFaceDrivenKeyTarget;
@@ -158,6 +162,66 @@ public class UmaViewerUI : MonoBehaviour
private void Update() private void Update()
{ {
if (LiveMode != LiveDropdown.value)
{
LiveMode = LiveDropdown.value;
if (LiveSelectPannel.activeSelf && currentLive != null)
{
foreach (var select in LiveSelectList.content.GetComponentsInChildren<Transform>())
{
if(select != LiveSelectList.content.transform)
{
Destroy(select.gameObject);
}
}
switch (LiveMode)
{
case 0:
LiveSelectImage.sprite = currentLive.Icon;
int mainCount = 0;
foreach (var motion in Main.AbMotions.Where(a => a.Name.StartsWith($"3d/motion/live/body/son{currentLive.MusicId}") && Path.GetFileName(a.Name).Split('_').Length == 4))
{
mainCount += 1;
}
LiveSelectInfoText.text = $"{currentLive.SongName}\nMain Members Count: {mainCount}";
for (int i = 0; i < mainCount; i++)
{
var chara = Instantiate(LiveSelectPrefab, LiveSelectList.content).GetComponent<LiveCharacterSelect>();
chara.IndexText.text = (i + 1).ToString();
chara.GetComponent<Button>().onClick.AddListener(() =>
{
chara.SelectChara(this);
foreach (var t in LiveSelectList.content.GetComponentsInChildren<LiveCharacterSelect>())
{
t.GetComponentInChildren<Text>().color = (t == chara ? Color.white : Color.black);
}
});
}
break;
case 1:
LiveSelectImage.sprite = currentLive.Icon;
LiveSelectInfoText.text = $"{currentLive.SongName}\nMembers Count: {currentLive.MemberCount}";
for (int i = 0; i < currentLive.MemberCount; i++)
{
var chara = Instantiate(LiveSelectPrefab, LiveSelectList.content).GetComponent<LiveCharacterSelect>();
chara.IndexText.text = (i + 1).ToString();
chara.GetComponent<Button>().onClick.AddListener(() =>
{
chara.SelectChara(this);
foreach (var t in LiveSelectList.content.GetComponentsInChildren<LiveCharacterSelect>())
{
t.GetComponentInChildren<Text>().color = (t == chara ? Color.white : Color.black);
}
});
}
break;
}
}
}
if (Builder.CurrentAudioSources.Count > 0) if (Builder.CurrentAudioSources.Count > 0)
{ {
AudioSource MianSource = Builder.CurrentAudioSources[0]; AudioSource MianSource = Builder.CurrentAudioSources[0];
@@ -597,22 +661,52 @@ public class UmaViewerUI : MonoBehaviour
Destroy(LiveSelectList.content.GetChild(i).gameObject); Destroy(LiveSelectList.content.GetChild(i).gameObject);
} }
currentLive = entry; if(LiveMode == 1)
LiveSelectImage.sprite = entry.Icon;
LiveSelectInfoText.text = $"{entry.SongName}\nMembers Count: {entry.MemberCount}";
for (int i = 0; i < entry.MemberCount; i++)
{ {
var chara = Instantiate(LiveSelectPrefab, LiveSelectList.content).GetComponent<LiveCharacterSelect>(); currentLive = entry;
chara.IndexText.text = (i + 1).ToString(); LiveSelectImage.sprite = entry.Icon;
chara.GetComponent<Button>().onClick.AddListener(() => LiveSelectInfoText.text = $"{entry.SongName}\nMembers Count: {entry.MemberCount}";
for (int i = 0; i < entry.MemberCount; i++)
{ {
chara.SelectChara(this); var chara = Instantiate(LiveSelectPrefab, LiveSelectList.content).GetComponent<LiveCharacterSelect>();
foreach (var t in LiveSelectList.content.GetComponentsInChildren<LiveCharacterSelect>()) chara.IndexText.text = (i + 1).ToString();
chara.GetComponent<Button>().onClick.AddListener(() =>
{ {
t.GetComponentInChildren<Text>().color = (t == chara ? Color.white : Color.black); chara.SelectChara(this);
} foreach (var t in LiveSelectList.content.GetComponentsInChildren<LiveCharacterSelect>())
}); {
t.GetComponentInChildren<Text>().color = (t == chara ? Color.white : Color.black);
}
});
}
} }
else if(LiveMode == 0)
{
currentLive = entry;
LiveSelectImage.sprite = entry.Icon;
int mainCount = 0;
foreach (var motion in Main.AbMotions.Where(a => a.Name.StartsWith($"3d/motion/live/body/son{entry.MusicId}") && Path.GetFileName(a.Name).Split('_').Length == 4))
{
mainCount += 1;
}
LiveSelectInfoText.text = $"{entry.SongName}\nMain Members Count: {mainCount}";
for (int i = 0; i < mainCount; i++)
{
var chara = Instantiate(LiveSelectPrefab, LiveSelectList.content).GetComponent<LiveCharacterSelect>();
chara.IndexText.text = (i + 1).ToString();
chara.GetComponent<Button>().onClick.AddListener(() =>
{
chara.SelectChara(this);
foreach (var t in LiveSelectList.content.GetComponentsInChildren<LiveCharacterSelect>())
{
t.GetComponentInChildren<Text>().color = (t == chara ? Color.white : Color.black);
}
});
}
}
} }
void ListCostumes(CharaEntry chara, bool mini) void ListCostumes(CharaEntry chara, bool mini)
@@ -1065,7 +1065,7 @@ namespace Gallop
if (partR != 0) if (partR != 0)
{ {
leftEarMorph[partR - 1].weight = (((1 - weightRatio)) * ((float)_prevEarsKeyData.weight / 100)); rightEarMorph[partR - 1].weight = (((1 - weightRatio)) * ((float)_prevEarsKeyData.weight / 100));
} }
} }
else else
@@ -1081,7 +1081,7 @@ namespace Gallop
if (partR != 0) if (partR != 0)
{ {
leftEarMorph[partR - 1].weight = 0; rightEarMorph[partR - 1].weight = 0;
} }
} }
} }
@@ -1097,7 +1097,7 @@ namespace Gallop
if (curPartR != 0) if (curPartR != 0)
{ {
leftEarMorph[curPartR - 1].weight += weightRatio * ((float)updateInfo_.earCur.weight / 100); rightEarMorph[curPartR - 1].weight += weightRatio * ((float)updateInfo_.earCur.weight / 100);
} }
ChangeMorphEar(); ChangeMorphEar();
@@ -3,6 +3,9 @@ using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using static RootMotion.FinalIK.IKSolverVR; using static RootMotion.FinalIK.IKSolverVR;
using System.Linq;
using System.IO;
using static UnityEngine.Rendering.VirtualTexturing.Debugging;
namespace Gallop.Live.Cutt namespace Gallop.Live.Cutt
{ {
@@ -78,18 +81,45 @@ namespace Gallop.Live.Cutt
_keyArray[i] = data.worksheetList[0].charaMotSeqList[i].keys; _keyArray[i] = data.worksheetList[0].charaMotSeqList[i].keys;
} }
//Set Motion if (Director.instance.liveMode == 1)
int CharaPositionMax = Director.instance.allowCount;
_motionSequenceArray = new LiveTimelineMotionSequence[CharaPositionMax];
for (int i = 0; i < CharaPositionMax; i++)
{ {
_motionSequenceArray[i] = new LiveTimelineMotionSequence(); //Set Motion
_motionSequenceArray[i].Initialize(Director.instance.charaObjs[i], i, motionSequence[i], this); int CharaPositionMax = Director.instance.allowCount;
_motionSequenceArray = new LiveTimelineMotionSequence[CharaPositionMax];
for (int i = 0; i < CharaPositionMax; i++)
{
Debug.Log(i);
_motionSequenceArray[i] = new LiveTimelineMotionSequence();
_motionSequenceArray[i].Initialize(Director.instance.charaObjs[i], i, motionSequence[i], this);
}
} }
else if(Director.instance.liveMode == 0)
{
List<AnimationClip> Anims = new List<AnimationClip>();
//Get MotionList
foreach (var motion in UmaViewerMain.Instance.AbMotions.Where(a => a.Name.StartsWith($"3d/motion/live/body/son{Director.instance.live.MusicId}") && Path.GetFileName(a.Name).Split('_').Length == 4))
{
AssetBundle motionAB = UmaViewerBuilder.LoadOrGet(motion);
AnimationClip motionAnim = motionAB.LoadAsset<AnimationClip>(Path.GetFileName(motion.Name).Split('.')[0]);
Anims.Add(motionAnim);
}
//Set Motion
int CharaPositionMax = Director.instance.allowCount;
_motionSequenceArray = new LiveTimelineMotionSequence[CharaPositionMax];
for (int i = 0; i < CharaPositionMax; i++)
{
_motionSequenceArray[i] = new LiveTimelineMotionSequence();
_motionSequenceArray[i].Initialize(Director.instance.charaObjs[i], i, motionSequence[i], this, Anims);
}
}
} }
public void AlterUpdate(float liveTime) public void AlterUpdate(float liveTime)
@@ -97,6 +127,7 @@ namespace Gallop.Live.Cutt
AlterUpdate_CharaMotionSequence(liveTime); AlterUpdate_CharaMotionSequence(liveTime);
AlterUpdate_FacialData(liveTime); AlterUpdate_FacialData(liveTime);
AlterUpdate_LipSync(liveTime); AlterUpdate_LipSync(liveTime);
//AlterLateUpdate_FormationOffset(liveTime);
} }
public void AlterUpdate_CharaMotionSequence(float liveTime) public void AlterUpdate_CharaMotionSequence(float liveTime)
@@ -208,6 +239,32 @@ namespace Gallop.Live.Cutt
} }
} }
private void AlterLateUpdate_FormationOffset(float liveTime)
{
var formationList = data.worksheetList[0].formationOffsetSet.Init();
for (int i = 0; i < Director.instance.characterCount; i++)
{
LiveTimelineKeyIndex curKey = AlterUpdate_Key(formationList[i], liveTime);
if (curKey != null && curKey.index != -1)
{
LateUpdateFormationOffset_Transform(i, curKey, liveTime);
}
}
}
public void LateUpdateFormationOffset_Transform(int targetIndex, LiveTimelineKeyIndex curKeyIndex, float time)
{
LiveTimelineKeyFormationOffsetData curKey = curKeyIndex.key as LiveTimelineKeyFormationOffsetData;
LiveTimelineKeyFormationOffsetData nextKey = curKeyIndex.nextKey as LiveTimelineKeyFormationOffsetData;
Director.instance.charaObjs[targetIndex].position = curKey.Position;
}
public static void FindTimelineKeyCurrent(out LiveTimelineKeyIndex curKey, ILiveTimelineKeyDataList keys, float curTime) public static void FindTimelineKeyCurrent(out LiveTimelineKeyIndex curKey, ILiveTimelineKeyDataList keys, float curTime)
{ {
curKey = keys.FindCurrentKey(curTime); curKey = keys.FindCurrentKey(curTime);
@@ -111,6 +111,7 @@ namespace Gallop.Live.Cutt
[System.Serializable] [System.Serializable]
public class LiveTimelineFormationOffsetData public class LiveTimelineFormationOffsetData
{ {
private const int DATA_LIST_SIZE = 20; private const int DATA_LIST_SIZE = 20;
public LiveTimelineKeyFormationOffsetDataList centerKeys; // 0x10 public LiveTimelineKeyFormationOffsetDataList centerKeys; // 0x10
public LiveTimelineKeyFormationOffsetDataList left1Keys; // 0x18 public LiveTimelineKeyFormationOffsetDataList left1Keys; // 0x18
@@ -133,5 +134,10 @@ namespace Gallop.Live.Cutt
public LiveTimelineKeyFormationOffsetDataList place19Keys; // 0xA0 public LiveTimelineKeyFormationOffsetDataList place19Keys; // 0xA0
public LiveTimelineKeyFormationOffsetDataList place20Keys; // 0xA8 public LiveTimelineKeyFormationOffsetDataList place20Keys; // 0xA8
private readonly ILiveTimelineKeyDataList[] _cacheDataList; // 0xB0 private readonly ILiveTimelineKeyDataList[] _cacheDataList; // 0xB0
public List<LiveTimelineKeyFormationOffsetDataList> Init()
{
return new List<LiveTimelineKeyFormationOffsetDataList> { centerKeys, left1Keys , right1Keys, left2Keys, right2Keys, place06Keys, place07Keys, place08Keys, place09Keys, place10Keys, place11Keys, place12Keys, place13Keys, place14Keys, place15Keys, place16Keys, place17Keys, place18Keys, place19Keys, place20Keys };
}
} }
} }
@@ -1,6 +1,7 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using static RootMotion.Demos.CharacterMeleeDemo.Action;
namespace Gallop.Live.Cutt namespace Gallop.Live.Cutt
{ {
@@ -28,8 +29,22 @@ namespace Gallop.Live.Cutt
private bool _needChange; private bool _needChange;
private LiveTimelineKeyCharaMotionData _prevKey; private LiveTimelineKeyCharaMotionData _prevKey;
public void Initialize(Transform target, int targetIndex, int seqDataIndex, LiveTimelineControl timelineControl) private AnimationClip _targetAnim = null;
public void Initialize(Transform target, int targetIndex, int seqDataIndex, LiveTimelineControl timelineControl, List<AnimationClip> animclips = null)
{ {
if(animclips != null)
{
if (targetIndex < Director.instance.charaAnims.Count)
{
_targetAnim = animclips[targetIndex];
_tempAnim = Director.instance.charaAnims[targetIndex];
_tempAnim.AddClip(_targetAnim, _targetAnim.name);
}
return;
}
_tempTarget = target; _tempTarget = target;
_targetIndex = targetIndex; _targetIndex = targetIndex;
@@ -56,6 +71,16 @@ namespace Gallop.Live.Cutt
public void AlterUpdate(float currentTime) public void AlterUpdate(float currentTime)
{ {
if(Director.instance.liveMode == 0)
{
if(_targetAnim != null)
{
_tempAnim[_targetAnim.name].time = currentTime;
_tempAnim.Play(_targetAnim.name);
}
return;
}
if (_currentKey != null && _tempAnim != null) if (_currentKey != null && _tempAnim != null)
{ {
LiveTimelineKeyIndex curKey = LiveTimelineControl.AlterUpdate_Key(_currentKey, currentTime); LiveTimelineKeyIndex curKey = LiveTimelineControl.AlterUpdate_Key(_currentKey, currentTime);
@@ -13,6 +13,7 @@ using System.Data;
using System.Runtime.Remoting.Metadata.W3cXsd2001; using System.Runtime.Remoting.Metadata.W3cXsd2001;
using CriWare; using CriWare;
using static UmaViewerAudio; using static UmaViewerAudio;
using UnityEngine.SceneManagement;
namespace Gallop.Live namespace Gallop.Live
{ {
@@ -342,6 +343,8 @@ namespace Gallop.Live
public int characterCount = 0; public int characterCount = 0;
public int allowCount = 0; public int allowCount = 0;
public int liveMode = 0;
private void Awake() private void Awake()
{ {
if (live != null) if (live != null)
@@ -379,9 +382,23 @@ namespace Gallop.Live
} }
} }
public void InitializeTimeline(int count) public void InitializeTimeline(List<LiveCharacterSelect> characters, int mode)
{ {
allowCount = count; liveMode = mode;
allowCount = characters.Count;
for (int i = 0; i < characters.Count; i++)
{
if (characters[i].CharaEntry.Name != "")
{
characterCount += 1;
}
}
if (characterCount == 1)
{
_soloMode = true;
}
_liveTimelineControl.InitCharaMotionSequence(_liveTimelineControl.data.characterSettings.motionSequenceIndices); _liveTimelineControl.InitCharaMotionSequence(_liveTimelineControl.data.characterSettings.motionSequenceIndices);
@@ -410,19 +427,6 @@ namespace Gallop.Live
{ {
Debug.Log(songid); Debug.Log(songid);
for (int i = 0; i < characters.Count; i++)
{
if (characters[i].CharaEntry.Name != "")
{
characterCount += 1;
}
}
if(characterCount == 1)
{
_soloMode = true;
}
if (!_soloMode) if (!_soloMode)
{ {
for (int i = 0; i < characters.Count; i++) for (int i = 0; i < characters.Count; i++)
@@ -501,6 +505,12 @@ namespace Gallop.Live
void Update() void Update()
{ {
if (Input.GetKeyDown(KeyCode.Escape))
{
SceneManager.LoadScene("Version2");
AssetBundle.UnloadAllAssetBundles(true);
}
if (_isLiveSetup) if (_isLiveSetup)
{ {
if(_syncTime == false) if(_syncTime == false)