Step 1:
Make Canvas within LoadingImage and in it Make a slider from UI menu.
And Create a Button to Load your desired level
Then Create a script LoadLevelAsync
Write the following code
1: public GameObject loadingImage;
2: public Slider slider;
3: private AsyncOperation async;
4: public void ClickAsync(int level)
5: {
6: loadingImage.SetActive(true);
7: StartCoroutine(LoadLevelWithBar(level));
8: }
9:
10: IEnumerator LoadLevelWithBar(int level)
11: {
12: async = Application.LoadLevelAsync(level);
13: while (!async.isDone)
14: {
15: slider.value = async.progress;
16: yield return null;
17: }
18: }
Comments
Post a Comment