i have 2 scenes in my game
i wish to make a progress bar in first scene according to waiting time to load second scene.
How can i do it with progrss bar.
Is anty other method with image to do it?
i have 2 scenes in my game
i wish to make a progress bar in first scene according to waiting time to load second scene.
How can i do it with progrss bar.
Is anty other method with image to do it?
Calling LoadLevelAsync like TheDarkVoid suggested will start the loading process. You could put it in a coroutine so other parts of the game can keep running. It returns an AsyncOperation. You can check ‘isDone’ to see if it’s done, or ‘progress’ to get the progress (0-1). Note that progress doesn’t work well in the editor, but is more accurate in builds.
Then you need to display the progress. Using Unity GUI, you can draw two textures: one for the empty bar background, and one for the filled progress.
public Texture2D emptyProgressBar; // Set this in inspector.
public Texture2D fullProgressBar; // Set this in inspector.
private AsyncOperation async = null; // When assigned, load is in progress.
private IEnumerator LoadALevel(string levelName) {
async = Application.LoadLevelAsync(levelName);
yield return async;
}
void OnGUI() {
if (async != null) {
GUI.DrawTexture(Rect(0, 0, 100, 50), emptyProgressBar);
GUI.DrawTexture(Rect(0, 0, 100 * async.progress, 50), fullProgressBar);
}
}
Take a look at LoadLevelAsync, it allows you to load a level and still have other stuff going on like a loading screen. It requires unity pro though, as far as i’m aware there’s no way to archive this without pro.