Add files via upload
This commit is contained in:
parent
82aab308f0
commit
310f5c8838
54 changed files with 2357 additions and 0 deletions
61
Tools/SceneManager/Loader.cs
Normal file
61
Tools/SceneManager/Loader.cs
Normal file
|
@ -0,0 +1,61 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public static class Loader{
|
||||
|
||||
class LoadingMonoBehaviour : MonoBehaviour { }
|
||||
|
||||
static Action onLoaderCallback;
|
||||
static AsyncOperation loadingAsyncOperation;
|
||||
|
||||
public static void Load(int scene){
|
||||
onLoaderCallback = () => {
|
||||
GameObject loadingGameObject = new GameObject("LoadingGameObject");
|
||||
loadingGameObject.AddComponent<LoadingMonoBehaviour>().StartCoroutine(LoadSceneAsync(scene));
|
||||
};
|
||||
|
||||
SceneManager.LoadScene("Loading");
|
||||
}
|
||||
public static void Load(string scene){
|
||||
onLoaderCallback = () => {
|
||||
GameObject loadingGameObject = new GameObject("LoadingGameObject");
|
||||
loadingGameObject.AddComponent<LoadingMonoBehaviour>().StartCoroutine(LoadSceneAsync(scene));
|
||||
};
|
||||
|
||||
SceneManager.LoadScene("Loading");
|
||||
}
|
||||
|
||||
static IEnumerator LoadSceneAsync(int scene){
|
||||
yield return null;
|
||||
loadingAsyncOperation = SceneManager.LoadSceneAsync(scene);
|
||||
|
||||
while (!loadingAsyncOperation.isDone){
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
static IEnumerator LoadSceneAsync(string scene){
|
||||
yield return null;
|
||||
loadingAsyncOperation = SceneManager.LoadSceneAsync(scene);
|
||||
|
||||
while (!loadingAsyncOperation.isDone){
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static float GetLoadingProgress(){
|
||||
if(loadingAsyncOperation != null){
|
||||
return loadingAsyncOperation.progress;
|
||||
}else{
|
||||
return 0f;
|
||||
}
|
||||
}
|
||||
|
||||
public static void LoaderCallback(){
|
||||
if(onLoaderCallback != null){
|
||||
onLoaderCallback();
|
||||
onLoaderCallback = null;
|
||||
}
|
||||
}
|
||||
}
|
11
Tools/SceneManager/Loader.cs.meta
Normal file
11
Tools/SceneManager/Loader.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f063a9d603510c141ab14838d5426a9b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
14
Tools/SceneManager/LoaderCallback.cs
Normal file
14
Tools/SceneManager/LoaderCallback.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class LoaderCallback : MonoBehaviour{
|
||||
|
||||
bool isFirstUpdate = true;
|
||||
|
||||
// Update is called once per frame
|
||||
void Update(){
|
||||
if (isFirstUpdate){
|
||||
isFirstUpdate = false;
|
||||
Loader.LoaderCallback();
|
||||
}
|
||||
}
|
||||
}
|
11
Tools/SceneManager/LoaderCallback.cs.meta
Normal file
11
Tools/SceneManager/LoaderCallback.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 26cb7a3b5197df940891506a87636cf7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
17
Tools/SceneManager/LoadingProgressBar.cs
Normal file
17
Tools/SceneManager/LoadingProgressBar.cs
Normal file
|
@ -0,0 +1,17 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class LoadingProgressBar : MonoBehaviour{
|
||||
|
||||
Image 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();
|
||||
}
|
||||
}
|
11
Tools/SceneManager/LoadingProgressBar.cs.meta
Normal file
11
Tools/SceneManager/LoadingProgressBar.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 79bedd11df41bee44a527b2e4e718d17
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue