- Home /
Question by
VicciGames · Jul 10, 2013 at 01:43 PM ·
scenescene-loadingscene-switchingasyncactivation
AsyncOperation "studders" next scene load and Scene speed problem
To clear some confusion, by studder I mean the next scene repeats itself over and over (I can show a video if that helps) until it is actually fully loaded. Now I do have a script that waits until the scene is fully loaded and then activate the scene using sceneactivation. ALSO, with the scene that has the async script inside it, the scene starts of reeaally fast and then after a few seconds it jumps to its regular speed. Thanks everyone. If anyone needs to see it in video, I can provide the link.
Here's my script:
using UnityEngine;
using System.Collections;
public class LoadingScript : MonoBehaviour {
public string destinationScene;
IEnumerator Start() {
AsyncOperation async = Application.LoadLevelAsync(destinationScene.ToString());
Application.backgroundLoadingPriority = ThreadPriority.Normal;
yield return async;
if(!async.isDone) {
async.allowSceneActivation = false;
}
else {
async.allowSceneActivation = true;
}
}
public void Update() {
gameObject.GetComponent<GUIText>().guiText.text = "Loading " + destinationScene.ToString();
}
}
Comment