Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine.UI;
- public class LoadingScreen : MonoBehaviour {
- public GameObject LoadingScene;
- public Image LoadingBar;
- public GameObject MainCamera;
- private bool InputCheck = false;
- public void LoadLevel ()
- {
- if (PlayerPrefs.GetInt ("Level Completed") > 1)
- {
- GameManager.currentLevel = PlayerPrefs.GetInt ("Level Completed");
- } else
- {
- GameManager.currentLevel = 1;
- }
- StartCoroutine (LevelCoroutine ());
- }
- IEnumerator LevelCoroutine ()
- {
- MainCamera.GetComponent <MainMenu> ().enabled = false;
- LoadingScene.SetActive (true);
- AsyncOperation async = SceneManager.LoadSceneAsync (GameManager.currentLevel);
- async.allowSceneActivation = false;
- yield return new WaitForSeconds (5F);
- async.allowSceneActivation = true;
- /*while (!async.isDone)
- {
- LoadingBar.fillAmount = async.progress / 0.9f;
- yield return null;
- }*/
- }
- void Update()
- {
- //NOCH NICHT FERTIG! BITTE UMBAUN SO DASS ER WIRKLICHT ASYNCHRON REINGEHT! SIEHE OBEN IN DER COROUTINE (musst async.allowSceneAction auf true setzen)
- /*if(Input.GetButtonDown("XButton") && InputCheck == false)
- {
- InputCheck = true;
- SceneManager.LoadScene (GameManager.currentLevel);
- GetComponent<LoadingScreen> ().enabled = false;
- }*/
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement