Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice

Resolved Access NetworkManager after switching scenes?

Discussion in 'Netcode for GameObjects' started by nhulston, Jun 14, 2021.

  1. nhulston

    nhulston

    Joined:
    Nov 26, 2019
    Posts:
    3
    How do I access the NetworkManager after switching scenes? I'm currently switching the scene with:
    Code (CSharp):
    1. NetworkSceneManager.SwitchScene(mySceneName);
    but then the clients/host can't access the NetworkManager after that because obviously, the NetworkManager game object was in a different scene.
     
    Picaresque likes this.
  2. luke-unity

    luke-unity

    Joined:
    Sep 30, 2020
    Posts:
    306
    The NetworkManager by default should mark itself as "DontDestroyOnLoad" and will persist across scene changes. You should be able to access the NetworkManager via `NetworkManager.Singleton`.
     
    nhulston likes this.