Reworked the dialogue system
Now the dialogue can use tags to add special effects Reorganized project structure, updating may require adding some using statements
This commit is contained in:
parent
95bad523b9
commit
0e8b8b1835
25 changed files with 1912 additions and 1266 deletions
|
@ -3,67 +3,69 @@ using System.Collections;
|
|||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public static class Loader{
|
||||
namespace SimpleTools.SceneManagement {
|
||||
public static class Loader {
|
||||
|
||||
class LoadingMonoBehaviour : MonoBehaviour { }
|
||||
class LoadingMonoBehaviour : MonoBehaviour { }
|
||||
|
||||
static Action onLoaderCallback;
|
||||
static AsyncOperation loadingAsyncOperation;
|
||||
static Action onLoaderCallback;
|
||||
static AsyncOperation loadingAsyncOperation;
|
||||
|
||||
/// <summary>Load a scene with a loading scene
|
||||
/// <para>It requires a scene called "Loading" where the loading screen is located.</para>
|
||||
/// </summary>
|
||||
public static void Load(int scene){
|
||||
onLoaderCallback = () => {
|
||||
GameObject loadingGameObject = new GameObject("LoadingGameObject");
|
||||
loadingGameObject.AddComponent<LoadingMonoBehaviour>().StartCoroutine(LoadSceneAsync(scene));
|
||||
};
|
||||
/// <summary>Load a scene with a loading scene
|
||||
/// <para>It requires a scene called "Loading" where the loading screen is located.</para>
|
||||
/// </summary>
|
||||
public static void Load(int scene) {
|
||||
onLoaderCallback = () => {
|
||||
GameObject loadingGameObject = new GameObject("LoadingGameObject");
|
||||
loadingGameObject.AddComponent<LoadingMonoBehaviour>().StartCoroutine(LoadSceneAsync(scene));
|
||||
};
|
||||
|
||||
SceneManager.LoadScene("Loading");
|
||||
}
|
||||
/// <summary>Load a scene with a loading scene
|
||||
/// <para>It requires a scene called "Loading" where the loading screen is located.</para>
|
||||
/// </summary>
|
||||
public static void Load(string scene){
|
||||
onLoaderCallback = () => {
|
||||
GameObject loadingGameObject = new GameObject("LoadingGameObject");
|
||||
loadingGameObject.AddComponent<LoadingMonoBehaviour>().StartCoroutine(LoadSceneAsync(scene));
|
||||
};
|
||||
SceneManager.LoadScene("Loading");
|
||||
}
|
||||
/// <summary>Load a scene with a loading scene
|
||||
/// <para>It requires a scene called "Loading" where the loading screen is located.</para>
|
||||
/// </summary>
|
||||
public static void Load(string scene) {
|
||||
onLoaderCallback = () => {
|
||||
GameObject loadingGameObject = new GameObject("LoadingGameObject");
|
||||
loadingGameObject.AddComponent<LoadingMonoBehaviour>().StartCoroutine(LoadSceneAsync(scene));
|
||||
};
|
||||
|
||||
SceneManager.LoadScene("Loading");
|
||||
}
|
||||
SceneManager.LoadScene("Loading");
|
||||
}
|
||||
|
||||
static IEnumerator LoadSceneAsync(int scene){
|
||||
yield return null;
|
||||
loadingAsyncOperation = SceneManager.LoadSceneAsync(scene);
|
||||
|
||||
while (!loadingAsyncOperation.isDone){
|
||||
static IEnumerator LoadSceneAsync(int scene) {
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
static IEnumerator LoadSceneAsync(string scene){
|
||||
yield return null;
|
||||
loadingAsyncOperation = SceneManager.LoadSceneAsync(scene);
|
||||
loadingAsyncOperation = SceneManager.LoadSceneAsync(scene);
|
||||
|
||||
while (!loadingAsyncOperation.isDone){
|
||||
while (!loadingAsyncOperation.isDone) {
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
static IEnumerator LoadSceneAsync(string scene) {
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
loadingAsyncOperation = SceneManager.LoadSceneAsync(scene);
|
||||
|
||||
/// <summary>Returns the loading progress
|
||||
/// </summary>
|
||||
public static float GetLoadingProgress(){
|
||||
if(loadingAsyncOperation != null){
|
||||
return loadingAsyncOperation.progress;
|
||||
}else{
|
||||
return 0f;
|
||||
while (!loadingAsyncOperation.isDone) {
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void LoaderCallback(){
|
||||
if(onLoaderCallback != null){
|
||||
onLoaderCallback();
|
||||
onLoaderCallback = null;
|
||||
/// <summary>Returns the loading progress
|
||||
/// </summary>
|
||||
public static float GetLoadingProgress() {
|
||||
if (loadingAsyncOperation != null) {
|
||||
return loadingAsyncOperation.progress;
|
||||
} else {
|
||||
return 0f;
|
||||
}
|
||||
}
|
||||
|
||||
public static void LoaderCallback() {
|
||||
if (onLoaderCallback != null) {
|
||||
onLoaderCallback();
|
||||
onLoaderCallback = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,14 +1,16 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class LoaderCallback : MonoBehaviour{
|
||||
namespace SimpleTools.SceneManagement {
|
||||
public class LoaderCallback : MonoBehaviour {
|
||||
|
||||
bool isFirstUpdate = true;
|
||||
bool isFirstUpdate = true;
|
||||
|
||||
// Update is called once per frame
|
||||
void Update(){
|
||||
if (isFirstUpdate){
|
||||
isFirstUpdate = false;
|
||||
Loader.LoaderCallback();
|
||||
// Update is called once per frame
|
||||
void Update() {
|
||||
if (isFirstUpdate) {
|
||||
isFirstUpdate = false;
|
||||
Loader.LoaderCallback();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,17 +1,19 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class LoadingProgressBar : MonoBehaviour{
|
||||
namespace SimpleTools.SceneManagement {
|
||||
public class LoadingProgressBar : MonoBehaviour {
|
||||
|
||||
Image image;
|
||||
Image image;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Awake(){
|
||||
image = transform.GetComponent<Image>();
|
||||
// Start is called before the first frame update
|
||||
void Awake() {
|
||||
image = transform.GetComponent<Image>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update() {
|
||||
image.fillAmount = Loader.GetLoadingProgress();
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update(){
|
||||
image.fillAmount = Loader.GetLoadingProgress();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue