Advertisement
Guest User

Untitled

a guest
May 3rd, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. using UnityEngine.UI;
  2.  
  3.  
  4. public class LoadingScreen : MonoBehaviour {
  5.  
  6. public GameObject LoadingScene;
  7. public Image LoadingBar;
  8.  
  9. public GameObject MainCamera;
  10.  
  11. private bool InputCheck = false;
  12.  
  13.  
  14. public void LoadLevel ()
  15. {
  16.  
  17. if (PlayerPrefs.GetInt ("Level Completed") > 1)
  18. {
  19. GameManager.currentLevel = PlayerPrefs.GetInt ("Level Completed");
  20.  
  21. } else
  22. {
  23. GameManager.currentLevel = 1;
  24. }
  25.  
  26. StartCoroutine (LevelCoroutine ());
  27.  
  28. }
  29.  
  30. IEnumerator LevelCoroutine ()
  31. {
  32. MainCamera.GetComponent <MainMenu> ().enabled = false;
  33.  
  34. LoadingScene.SetActive (true);
  35. AsyncOperation async = SceneManager.LoadSceneAsync (GameManager.currentLevel);
  36.  
  37. async.allowSceneActivation = false;
  38.  
  39.  
  40.  
  41.  
  42. yield return new WaitForSeconds (5F);
  43.  
  44. async.allowSceneActivation = true;
  45.  
  46. /*while (!async.isDone)
  47. {
  48. LoadingBar.fillAmount = async.progress / 0.9f;
  49. yield return null;
  50. }*/
  51.  
  52. }
  53.  
  54. void Update()
  55. {
  56. //NOCH NICHT FERTIG! BITTE UMBAUN SO DASS ER WIRKLICHT ASYNCHRON REINGEHT! SIEHE OBEN IN DER COROUTINE (musst async.allowSceneAction auf true setzen)
  57. /*if(Input.GetButtonDown("XButton") && InputCheck == false)
  58. {
  59. InputCheck = true;
  60. SceneManager.LoadScene (GameManager.currentLevel);
  61. GetComponent<LoadingScreen> ().enabled = false;
  62. }*/
  63. }
  64.  
  65.  
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement