improve scene loading
This commit is contained in:
@@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||
using Mono.Data.Sqlite;
|
||||
using System.Data;
|
||||
using Assets.Scripts;
|
||||
using System.IO;
|
||||
|
||||
public class UmaDatabaseController
|
||||
{
|
||||
@@ -60,11 +61,13 @@ public class UmaDatabaseController
|
||||
{
|
||||
if(Config.Instance.WorkMode == WorkMode.Standalone)
|
||||
{
|
||||
if(!File.Exists($@"{Config.Instance.MainPath}\meta_umaviewer")) throw new Exception();
|
||||
metaDb = new SqliteConnection($@"Data Source={Config.Instance.MainPath}\meta_umaviewer;");
|
||||
masterDb = new SqliteConnection($@"Data Source={Config.Instance.MainPath}\master\master_umaviewer.mdb;");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!File.Exists($@"{Config.Instance.MainPath}\meta")) throw new Exception();
|
||||
metaDb = new SqliteConnection($@"Data Source={Config.Instance.MainPath}\meta;");
|
||||
masterDb = new SqliteConnection($@"Data Source={Config.Instance.MainPath}\master\master.mdb;");
|
||||
}
|
||||
@@ -214,10 +217,10 @@ public class UmaDatabaseController
|
||||
|
||||
public void CloseAllConnection()
|
||||
{
|
||||
masterDb.Close();
|
||||
metaDb.Close();
|
||||
masterDb.Dispose();
|
||||
metaDb.Dispose();
|
||||
masterDb?.Close();
|
||||
metaDb?.Close();
|
||||
masterDb?.Dispose();
|
||||
metaDb?.Dispose();
|
||||
SqliteConnection.ClearAllPools();
|
||||
GC.Collect();
|
||||
GC.WaitForPendingFinalizers();
|
||||
|
||||
@@ -19,7 +19,7 @@ public class UmaSceneController:MonoBehaviour
|
||||
DontDestroyOnLoad(this);
|
||||
}
|
||||
|
||||
public void LoadScene(string name, Action OnSceneloaded, Action OnLastSceneUnloaded)
|
||||
public void LoadScene(string name, Action OnSceneloaded = null, Action OnLastSceneUnloaded = null)
|
||||
{
|
||||
StartCoroutine(LoadLiveSceneAsync(name, OnSceneloaded, OnLastSceneUnloaded));
|
||||
}
|
||||
@@ -45,13 +45,13 @@ public class UmaSceneController:MonoBehaviour
|
||||
// Wait until the last operation fully loads to return anything
|
||||
yield return new WaitUntil(()=> asyncLoad.isDone);
|
||||
|
||||
OnSceneloaded();
|
||||
OnSceneloaded?.Invoke();
|
||||
|
||||
// Unload the previous Scene
|
||||
AsyncOperation asyncUnLoad = SceneManager.UnloadSceneAsync(currentScene);
|
||||
yield return new WaitUntil(() => asyncUnLoad.isDone);
|
||||
|
||||
OnLastSceneUnloaded();
|
||||
OnLastSceneUnloaded?.Invoke();
|
||||
|
||||
animation.Play("SceneTransition_e");
|
||||
yield return new WaitUntil(() => !animation.isPlaying);
|
||||
|
||||
@@ -495,11 +495,14 @@ namespace Gallop.Live
|
||||
}
|
||||
}
|
||||
|
||||
bool isExit;
|
||||
void Update()
|
||||
{
|
||||
if (isExit) return;
|
||||
if (Input.GetKeyDown(KeyCode.Escape))
|
||||
{
|
||||
SceneManager.LoadScene("Version2");
|
||||
isExit = true;
|
||||
UmaSceneController.instance.LoadScene("Version2");
|
||||
AssetBundle.UnloadAllAssetBundles(true);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user