Hello I am trying to setup a loading screen, as a title screen for my game before it goes to the lobby, I have setup my code as follows:
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class NewBehaviourScript : MonoBehaviour
{
// Use this for initialization
void Start()
{
StartCoroutine(AsynchronousLoad(1));
}
// Update is called once per frame
void Update()
{
}
bool canPlayerFire = true;
IEnumerator coRoutineTest()
{
Debug.Log("Fire");
canPlayerFire = false;
yield return new WaitForSeconds(3);
canPlayerFire = true;
}
IEnumerator AsynchronousLoad(int lvl)
{
yield return null;
AsyncOperation ao = SceneManager.LoadSceneAsync(lvl);
ao.allowSceneActivation = false;
while (!ao.isDone)
{
// [0, 0.9] > [0, 1]
float progress = Mathf.Clamp01(ao.progress / 0.9f);
// Loading completed
if (ao.progress == 0.9f)
{
}
yield return null;
}
}
}
after running it, it says cherry pop is loading but it does not load or progress. I can not figure out what is wrong, can anyone offer a lil help?