This commit is contained in:
左右看
2023-07-05 02:25:44 +08:00
21 changed files with 1381 additions and 351 deletions
-32
View File
@@ -1,32 +0,0 @@
using UnityEngine;
using System.Collections;
public class CallAfterDelay : MonoBehaviour
{
float delay;
System.Action action;
// Will never call this frame, always the next frame at the earliest
public static CallAfterDelay Create(float delay, System.Action action)
{
CallAfterDelay cad = new GameObject("CallAfterDelay").AddComponent<CallAfterDelay>();
cad.delay = delay;
cad.action = action;
return cad;
}
float age;
void Update()
{
if (age > delay)
{
action();
Destroy(gameObject);
}
}
void LateUpdate()
{
age += Time.deltaTime;
}
}
+60
View File
@@ -0,0 +1,60 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class UmaSceneController:MonoBehaviour
{
public static UmaSceneController instance;
public GameObject CavansPrefab;
public GameObject CavansInstance;
private void Awake()
{
if (instance)
{
Destroy(this.gameObject);
}
instance = this;
DontDestroyOnLoad(this);
}
public void LoadScene(string name, Action OnSceneloaded, Action OnLastSceneUnloaded)
{
StartCoroutine(LoadLiveSceneAsync(name, OnSceneloaded, OnLastSceneUnloaded));
}
IEnumerator LoadLiveSceneAsync(string sceneName, Action OnSceneloaded, Action OnLastSceneUnloaded)
{
if (CavansInstance)
{
Destroy(CavansInstance);
}
CavansInstance = Instantiate(CavansPrefab, transform);
var animation = CavansInstance.GetComponent<Animation>();
animation.Play("SceneTransition_s");
yield return new WaitUntil(() => !animation.isPlaying);
// Set the current Scene to be able to unload it later
Scene currentScene = SceneManager.GetActiveScene();
// The Application loads the Scene in the background at the same time as the current Scene.
AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive);
// Wait until the last operation fully loads to return anything
yield return new WaitUntil(()=> asyncLoad.isDone);
OnSceneloaded.Invoke();
// Unload the previous Scene
AsyncOperation asyncUnLoad = SceneManager.UnloadSceneAsync(currentScene);
yield return new WaitUntil(() => asyncUnLoad.isDone);
OnLastSceneUnloaded.Invoke();
animation.Play("SceneTransition_e");
yield return new WaitUntil(() => !animation.isPlaying);
Destroy(CavansInstance);
}
}
@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: d30491b056a700f48b6af3b340ae0caf
guid: 281012d668bdb724b978234aacdc0ef2
MonoImporter:
externalObjects: {}
serializedVersion: 2
+33 -54
View File
@@ -663,70 +663,49 @@ public class UmaViewerBuilder : MonoBehaviour
public void LoadLive(LiveEntry live, List<LiveCharacterSelect> characters)
{
characters.ForEach(a =>
{
if (a.CharaEntry == null || a.CostumeId == "")
{
//a.CharaEntry = Main.Characters[Random.Range(0, Main.Characters.Count)];
//a.CostumeId = "00";
}
});//fill empty
GameObject MainLive = new GameObject("Live");
GameObject Director = new GameObject("Director");
List<GameObject> transferObjs = new List<GameObject>() {
MainLive,
GameObject.Find("ViewerMain"),
GameObject.Find("Camera"),
GameObject.Find("Directional Light"),
GameObject.Find("AnimationCameraRoot")
};
Gallop.Live.Director mController = Director.AddComponent<Gallop.Live.Director>();
mController.live = live;
Instantiate(mController, MainLive.transform);
UmaSceneController.instance.LoadScene("LiveScene",
delegate ()
{
// Move the GameObject (you attach this in the Inspector) to the newly loaded Scene
transferObjs.ForEach(o => SceneManager.MoveGameObjectToScene(o, SceneManager.GetSceneByName("LiveScene")));
Destroy(Director);
characters.ForEach(a =>
{
if (a.CharaEntry == null || a.CostumeId == "")
{
//a.CharaEntry = Main.Characters[Random.Range(0, Main.Characters.Count)];
//a.CostumeId = "00";
}
});//fill empty
LoadLiveUma(characters);
Gallop.Live.Director mController = Director.AddComponent<Gallop.Live.Director>();
mController.live = live;
Instantiate(mController, MainLive.transform);
Gallop.Live.Director.instance.InitializeTimeline();
Destroy(Director);
//Gallop.Live.Director.instance.Play();
List<GameObject> transferObjs = new List<GameObject>();
transferObjs.Add(MainLive);
transferObjs.Add(GameObject.Find("ViewerMain"));
transferObjs.Add(GameObject.Find("GlobalShaderController"));
transferObjs.Add(GameObject.Find("Camera"));
transferObjs.Add(GameObject.Find("Directional Light"));
transferObjs.Add(GameObject.Find("AnimationCameraRoot"));
StartCoroutine(LoadLiveSceneAsync("LiveScene", transferObjs, live.MusicId, characters[0].CharaEntry.Id));
LoadLiveUma(characters);
},
delegate ()
{
Gallop.Live.Director.instance.InitializeTimeline();
Gallop.Live.Director.instance.Play(live.MusicId, characters[0].CharaEntry.Id);
}
);
}
IEnumerator LoadLiveSceneAsync(string sceneName, List<GameObject> go, int songid, int charaid)
{
// Set the current Scene to be able to unload it later
Scene currentScene = SceneManager.GetActiveScene();
// The Application loads the Scene in the background at the same time as the current Scene.
AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive);
// Wait until the last operation fully loads to return anything
while (!asyncLoad.isDone)
{
yield return null;
}
// Move the GameObject (you attach this in the Inspector) to the newly loaded Scene
foreach(var obj in go)
{
SceneManager.MoveGameObjectToScene(obj, SceneManager.GetSceneByName(sceneName));
}
// Unload the previous Scene
//Scene scene = SceneManager.GetSceneByName(sceneName);
//SceneManager.SetActiveScene(scene);
SceneManager.UnloadSceneAsync(currentScene);
Gallop.Live.Director.instance.Play(songid, charaid);
}
//Use CriWare Library
public void LoadLiveSoundCri(int songid, UmaDatabaseEntry SongAwb)
+2 -4
View File
@@ -198,6 +198,7 @@ public class UmaViewerUI : MonoBehaviour
public void LoadedAssetsAdd(UmaDatabaseEntry entry)
{
if (!LoadedAssetsPanel) return;
foreach (UmaUIContainer ui in LoadedAssetsPanel.GetComponentsInChildren<UmaUIContainer>())
{
if (ui.Name == Path.GetFileName(entry.Name)) return;
@@ -589,10 +590,7 @@ public class UmaViewerUI : MonoBehaviour
{
LiveTime = true;
SetEyeTrackingEnable(false);
GameObject.Find("LoadingCanvas").GetComponent<Canvas>().enabled = true;
CallAfterDelay.Create(0, () => {
Builder.LoadLive(currentLive, new List<LiveCharacterSelect>(selectlist));
});
Builder.LoadLive(currentLive, new List<LiveCharacterSelect>(selectlist));
LiveSelectPannel.SetActive(false);
}
}