Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Scene Management suggestions

Discussion in 'Netcode for GameObjects' started by BSimonSweet, Oct 3, 2022.

  1. BSimonSweet

    BSimonSweet

    Joined:
    Aug 17, 2022
    Posts:
    67
    Hi,

    I'm starting to explore Netcode For GameObject. It is a nice tool, but the scene management is a bit lacking I think.

    Here's a some ideas I had in mind :
    • Load multiples scenes in one request : right now, we can only load one scene at a time and we have to wait for the loading to completly ends before loading another scene.

      It would be really nice to be able to load a list of scenes.

      Code (CSharp):
      1. NetworkManager.SceneManager.LoadScenes("scene_A", "scene_B", ...);

      Why would it be useful ? Because it gives more freedom in the worflow, so we can split our levels in multiple scenes. And the server won't make multiple requests to load a level.

    • Possibility to pass a custom payload : this feature could give additional data to clients, for example which scene should be the active one.

      The payload can be struct, that is serializable by the server. On client side, the payload can be passed to SceneManager.OnSceneEvent and SceneManager.VerifySceneBeforeLoading events.

      Code (CSharp):
      1. var myPayload = new MyScenePayload
      2. {
      3.     activeScene = "scene_A",
      4.     playerGroup = "Allie"
      5. };
      6.  
      7. NetworkManager.SceneManager.LoadScenes(payload, "scene_A", "scene_B", ...);
      8.  
      9. // On client
      10.  
      11. private bool VerifySceneBeforeLoadingOnClient(int sceneindex[], string scenenames[], MyScenePayload payload)
      12. {
      13.     // I'm not sure if we can explicitly pass MyScenePayload as a parameter here, but it is to illustrate
      14.    
      15.     var myPlayerGroup = localPlayerReference.PlayerGroup;
      16.    
      17.     return myPlayerGroup == payload.playerGroup;
      18. }
    • Maybe those two features should also work to unload a scenes / scenes.
    That's all :) For now !
     
    CreativeChris likes this.