Optimize live loading
This commit is contained in:
@@ -10,6 +10,7 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UmaMusumeAudio;
|
using UmaMusumeAudio;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using static UmaViewerMain;
|
||||||
|
|
||||||
public class UmaViewerBuilder : MonoBehaviour
|
public class UmaViewerBuilder : MonoBehaviour
|
||||||
{
|
{
|
||||||
@@ -344,10 +345,11 @@ public class UmaViewerBuilder : MonoBehaviour
|
|||||||
RecursiveLoadAsset(entry);
|
RecursiveLoadAsset(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadLive(int id)
|
public void LoadLive(LiveEntry live)
|
||||||
{
|
{
|
||||||
var asset = UmaViewerMain.Instance.AbList.FirstOrDefault(a => a.Name.EndsWith("cutt_son" + id));
|
var asset = UmaViewerMain.Instance.AbList.FirstOrDefault(a => a.Name.EndsWith("cutt_son" + live.MusicId));
|
||||||
if (asset == null) return;
|
var BGasset = UmaViewerMain.Instance.AbList.FirstOrDefault(a => a.Name.EndsWith($"pfb_env_live{live.BackGroundId}_controller000"));
|
||||||
|
if (asset == null|| BGasset == null) return;
|
||||||
|
|
||||||
if (CurrentLiveContainer != null)
|
if (CurrentLiveContainer != null)
|
||||||
{
|
{
|
||||||
@@ -356,6 +358,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
|||||||
UnloadAllBundle();
|
UnloadAllBundle();
|
||||||
CurrentLiveContainer = new GameObject(Path.GetFileName(asset.Name)).AddComponent<UmaContainer>();
|
CurrentLiveContainer = new GameObject(Path.GetFileName(asset.Name)).AddComponent<UmaContainer>();
|
||||||
RecursiveLoadAsset(asset);
|
RecursiveLoadAsset(asset);
|
||||||
|
RecursiveLoadAsset(BGasset);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -818,7 +821,8 @@ public class UmaViewerBuilder : MonoBehaviour
|
|||||||
|
|
||||||
private void LoadProp(GameObject go)
|
private void LoadProp(GameObject go)
|
||||||
{
|
{
|
||||||
var prop = Instantiate(go, (go.name.Contains("Cutt_son") ? CurrentLiveContainer : CurrentOtherContainer).transform);
|
var container = (go.name.Contains("Cutt_son") || go.name.Contains("pfb_env_live")) ? CurrentLiveContainer : CurrentOtherContainer;
|
||||||
|
var prop = Instantiate(go, container.transform);
|
||||||
foreach (Renderer r in prop.GetComponentsInChildren<Renderer>())
|
foreach (Renderer r in prop.GetComponentsInChildren<Renderer>())
|
||||||
{
|
{
|
||||||
foreach (Material m in r.sharedMaterials)
|
foreach (Material m in r.sharedMaterials)
|
||||||
|
|||||||
@@ -61,18 +61,32 @@ public class UmaViewerMain : MonoBehaviour
|
|||||||
yield return UmaViewerDownload.DownloadText("https://www.tracenacademy.com/api/BasicLiveDataInfo", txt =>
|
yield return UmaViewerDownload.DownloadText("https://www.tracenacademy.com/api/BasicLiveDataInfo", txt =>
|
||||||
{
|
{
|
||||||
UmaLiveData = JArray.Parse(txt);
|
UmaLiveData = JArray.Parse(txt);
|
||||||
foreach (var item in UmaLiveData)
|
var asset = AbList.FirstOrDefault(a => a.Name.Equals("livesettings"));
|
||||||
|
if(asset != null)
|
||||||
{
|
{
|
||||||
if (!Lives.Where(c => c.MusicId == (int)item["musicId"]).Any())
|
string filePath = UmaDatabaseController.GetABPath(asset);
|
||||||
|
if (File.Exists(filePath))
|
||||||
{
|
{
|
||||||
Lives.Add(new LiveEntry()
|
AssetBundle bundle = AssetBundle.LoadFromFile(filePath);
|
||||||
|
foreach (var item in UmaLiveData)
|
||||||
{
|
{
|
||||||
MusicId = (int)item["musicId"],
|
if (!Lives.Where(c => c.MusicId == (int)item["musicId"]).Any())
|
||||||
songName = (string)item["songName"]
|
{
|
||||||
});
|
if (bundle.Contains((string)item["musicId"]))
|
||||||
|
{
|
||||||
|
TextAsset liveData = bundle.LoadAsset<TextAsset>((string)item["musicId"]);
|
||||||
|
|
||||||
|
Lives.Add(new LiveEntry(liveData.text)
|
||||||
|
{
|
||||||
|
MusicId = (int)item["musicId"],
|
||||||
|
songName = (string)item["songName"]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
UI.LoadLivePanels();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UI.LoadLivePanels();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,5 +107,18 @@ public class UmaViewerMain : MonoBehaviour
|
|||||||
{
|
{
|
||||||
public int MusicId;
|
public int MusicId;
|
||||||
public string songName;
|
public string songName;
|
||||||
|
public string BackGroundId;
|
||||||
|
public List<string[]> LiveSettings = new List<string[]>();
|
||||||
|
|
||||||
|
public LiveEntry(string data)
|
||||||
|
{
|
||||||
|
string[] lines = data.Split("\n"[0]);
|
||||||
|
for (int i = 1; i < lines.Length; i++)
|
||||||
|
{
|
||||||
|
LiveSettings.Add(lines[i].Split(','));
|
||||||
|
}
|
||||||
|
BackGroundId = LiveSettings[1][2];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ public class UmaViewerUI : MonoBehaviour
|
|||||||
var imageInstance1 = container.GetComponent<Image>();
|
var imageInstance1 = container.GetComponent<Image>();
|
||||||
container.Button.onClick.AddListener(() => {
|
container.Button.onClick.AddListener(() => {
|
||||||
HighlightChildImage(LiveList.content, imageInstance1);
|
HighlightChildImage(LiveList.content, imageInstance1);
|
||||||
Builder.LoadLive(live.MusicId);
|
Builder.LoadLive(live);
|
||||||
});
|
});
|
||||||
|
|
||||||
var CharaContainer = Instantiate(UmaContainerNoTMPPrefab, LiveSoundList.content).GetComponent<UmaUIContainer>();
|
var CharaContainer = Instantiate(UmaContainerNoTMPPrefab, LiveSoundList.content).GetComponent<UmaUIContainer>();
|
||||||
|
|||||||
Reference in New Issue
Block a user