Question by
TechTheAwesome · Nov 28, 2015 at 03:22 PM ·
not workingloadlevelasyncprogress
Why LoadLevelAsync dont give me progress, it is alwasys 0 ?
I wrote a simple script with startcoroutine() to load my level but when i run it, the async.progress always 0 every time i try, any help although it still take a long while for the level to load using UnityEngine; using System.Collections;
public class StartButton : MonoBehaviour
{
public GameObject start;
private int percent;
public string level;
public GameObject Text;
public GameObject Bg;
private AsyncOperation async;
// Update is called once per frame
void OnMouseUpAsButton ()
{
DestroyObject(start);
Bg.SetActive (true);
Text.SetActive (true);
StartCoroutine (LevelLoader ());
}
void Start()
{
Bg.SetActive (false);
Text.SetActive (false);
}
private IEnumerator LevelLoader ()
{
async = Application.LoadLevelAsync (level);
percent = (int)(async.progress*100);
if (!async.isDone)
{
Debug.Log(percent);
yield return null;
}
}
}
Comment