Hi, I’m trying to load a scene as a host in order for other clients to join the same scene as the host. In order to do so, I assign first the host by using this piece of code: NetworkManager.Singleton.StartHost();
Next, I want to load the next scene not by using the SceneManager but by using the NetworkManager.Singleton.SceneManager instead since I read in this thread that that way clients can join the very same scene as the host.
To do so, I previously stored the scene as gameScene = SceneManager.GetSceneByBuildIndex(1);, and I’m trying this piece of code: NetworkManager.Singleton.SceneManager.LoadScene(gameScene.name, LoadSceneMode.Single);
however, I’m getting the following error
The scene is in build list. In fact, I can load the scene pretty easily by using the SceneManager piece of code. Any idea of what could be causing this issue?
Thanks for replying. Indeed, when I check the scene with Debug.Log("gameScene.name: " + gameScene.name); the name seems to be null or empty, as nothing shows up on the log box. The way I’m retrieving the scene looks pretty straightforward to me, so I ran out of ideas about why I’m getting a null/empty scene.
Here’s the code I used to retrieve the scene: gameScene = SceneManager.GetSceneByBuildIndex(1);, which is the number 2 of the build.
Here’s also a picture of the build with the scenes in it:
and now it works. It also works by using the path directly in this manner: NetworkManager.Singleton.SceneManager.LoadScene(gameScenePath, LoadSceneMode.Single);