Hello,
I am trying to make a loading screen for my Door animation.
Let’s say i am going out of an area (Dinning area to Hallway) I want a loading screen in between to load everything in the next zone. i want to be sure that my zone is fully loaded before i completly zone in the next scene.
I have looked online. and all i can find are tutorials on how to make a loading screen with a button which is not what i am looking for.
I have a door. that rotates about 10~15 degrees that collides with a invisible gameObject. from that trigger, i want to load the next scene which is the “hallway”.
Here’s the code i have for the loading screen
using System.Collections;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class levelLoader : MonoBehaviour {
public GameObject loadingScreen;
public Slider slider;
public Text progressText;
public void LoadLevel(int sceneIndex)
{
StartCoroutine(LoadAsync(sceneIndex));
}
IEnumerator LoadAsync(int sceneIndex)
{
AsyncOperation operation = SceneManager.LoadSceneAsync("Hallway");
Debug.Log("loadingScreen Hallway");
loadingScreen.SetActive(true);
while (!operation.isDone)
{
float progress = Mathf.Clamp01(operation.progress / .9f);
slider.value = progress;
progressText.text = progress * 100f + "%";
yield return null;
}
}
}
I have no errors. but when i zone it gives me an loading screen the loading bar and % does not do anything.