Add files via upload

This commit is contained in:
Geri 2021-01-08 16:05:34 +01:00 committed by GitHub
parent 82aab308f0
commit 310f5c8838
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
54 changed files with 2357 additions and 0 deletions

View 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;
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f063a9d603510c141ab14838d5426a9b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View 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();
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 26cb7a3b5197df940891506a87636cf7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View 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();
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 79bedd11df41bee44a527b2e4e718d17
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: