Unity Netcode spawn objects on scene switch

Hello!

I have different scenes: MainMenu and InGame.

When pressing a button in the MainMenu, it loads the InGame scene using the Unity Scenemanager.

Now all pre-placed NetworkObjects are not (Network-)Spawned, showing the “Spawn”-Button in the inspector. How can I make it spawn automatically?

I do not want to use the Netcode.Instance.SceneManager, as I’d like to manage my scenes manually.

image

Note: At the point I’m loading the scene, NetworkManager.Singleton.StartHost(); has been called.

Then you need to disable scene management in the NetworkManager Inspector, read the manual section on custom scene management and be prepared to write and test a lot of code that would otherwise be a given. Not recommended unless you have plenty of network programming experience with Unity already.

Works as expected. If you disable built-in scene management, respectively load a scene with the UnityEngine SceneManager, it will not be networked. You would have to write that logic yourself that spawns in-scene network objects if they have a network component. And a lot more …

You may want to read my article on network scene flow. In summary, I’m going to use a single scene for everything. All other content are scenes that are additively loaded. Additive scene loading provides you with full control over scene loading and unloading, wether they are networked or local-only.

Hmm okay that is unfortunate. I will reconsider my choice then. :face_with_head_bandage:

Thanks, I can see this helping a lot. Great job on the quality of your blog :stuck_out_tongue: