using UnityEngine; using System.Collections; public class LevelAsyncLoader : MonoBehaviour { private string loadName; private float delay = 0; private AsyncOperation async; private float startTime; private bool isLoading; public void init(string levelName, float delay=0) { this.loadName = levelName; this.delay = delay; } void Start () { startTime = GameTime.time; } // Update is called once per frame void Update () { if(!isLoading) { if(GameTime.time - startTime > delay) { isLoading = true; StartCoroutine(loadScene()); } } else { Debuger.Log("Loading ("+loadName+") "+async.progress); } } IEnumerator loadScene() { async = Application.LoadLevelAsync(loadName); yield return async; } }