0
\$\begingroup\$

I have two scenes in the Hierarchy when running the game. And this script attached to empty GameObject:

using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; public class LoadScenes : MonoBehaviour { // Use this for initialization void Start() { if (!SceneManager.GetSceneByName("The Space Station").IsValid()) { SceneManager.LoadScene(1, LoadSceneMode.Additive); StartCoroutine(WaitForSceneLoad(SceneManager.GetSceneByName("The Space Station"))); } } public IEnumerator WaitForSceneLoad(Scene scene) { while (!scene.isLoaded) { yield return null; } SceneManager.SetActiveScene(SceneManager.GetSceneByBuildIndex(1)); } } 

But it's taking like 3-4 seconds until it's getting to the line:

SceneManager.SetActiveScene(SceneManager.GetSceneByBuildIndex(1)); 
\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

Scene loading always depends on resource (prefabs, game objects, audios, textures, etc.) usage. If scene has a lot of objects in it, or scripts instantiate objects in awake or start methods, scene loading will take much more time.

Async Object Management in Unity3D Forum.

LoadSceneAsync Unity3D Docs.

\$\endgroup\$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.