So I have an object, when the object is turned on the LoadScene function in the following code is called.
using UnityEngine;
using System.Collections;
public class LoadSceneWithLoadingBar : MonoBehaviour {
public UISlider m_Slider;
AsyncOperation m_Async;
public Object m_LoadScene = null;
void Awake()
{
DontDestroyOnLoad (gameObject);
}
// Update is called once per frame
void Update()
{
}
public void LoadScene()
{
StartCoroutine (StartSceneLoad ());
}
IEnumerator StartSceneLoad()
{
m_Async = Application.LoadLevelAsync(m_LoadScene.name);
while (!m_Async.isDone) {
yield return m_Async;
m_Slider.value = m_Async.progress;
}
//now it's done
Destroy (gameObject);
}
}
I’ve read a lot of articles about Async loading and this is basically what they all come down to. In the editor it just stalls, then loads the level, progress bar is unaffected. In a local build it just won’t load at all (or maybe it’s taking like 5 minutes+).
Any idea what’s wrong with this? I’ve tried it a few different ways but none of them work how I want it to.