Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Resolved Is it possible to use Addressables with NGO‘s integrated Scene Management?

Discussion in 'Netcode for GameObjects' started by NatureRaph, Feb 25, 2024.

  1. NatureRaph

    NatureRaph

    Joined:
    Aug 13, 2021
    Posts:
    8
    Hey guys,
    so I am using Unity Netcode and Addressables for loading parts of the map. So by starting the game it loads from the main menu the GamePlay Scene where player clones and so on are spawned and the first part of the map additionally via addressables. But the problem is that I think the SceneManager from the NetworkManager tries to sync the scene as I get the error that the location scene isn’t added to the build settings. As I am trying to load the Map parts locally and independent from the host, I don’t want to sync it. So my question is, is there a way to do this? So my location scene is basically only a plane(for testing).
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    6,659
    To load a synchronized scene:
    NetworkManager.Singleton.SceneManager.LoadScene(..)

    To load a non-synchronized scene:
    UnityEngine.SceneManager.LoadScene(..)

    I use the latter to load the UI scene additively for clients. A scene loaded via UnityEngine.SceneManager cannot contain any network synchronized objects.

    Any scene you load needs to be in the build list. It's just that Netcode warns you about this right away, but for non-networked scenes not in the build list these just won't load in a build because they don't exist in the build.

    Btw, when you load the map only on clients you'd have to ensure that this map is precisely the same for every client and that every client is authoritative when it comes to interacting (most likely: colliding) with the map. You also cannot synchronize anything in that map, for example if there are items placed in the map then every client gets to pick up that item, it cannot be a networked item.
    Why do you not want to sync the map?
     
    Last edited: Feb 26, 2024
  3. NatureRaph

    NatureRaph

    Joined:
    Aug 13, 2021
    Posts:
    8
    Thank you really much for your quick and detailed response. So I am using Addressables to load the map and have no NetworkObject in that scene but it says in runtime that I have to add it to the build list.
    So I want to load the map dynamically, meaning it depends where the individual player is. So that the whole map doesn’t need to be loaded. So it would be cool, when the map is synced, but then I would need Custom Scene Management, right? Actually I tried that one but Syncing of Scenes are my problem. I can do Scene Loading and Unloading in Custom Scene Management but I don’t really understand the docs about Syncing the Scenes properly.
     
  4. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    6,659
    Oh, I see, the scene is in the addressable. I overlooked that.

    There's an issue on GitHub for this. Loading scenes from addressables is not implemented but a user shared a script that is supposed to do that further down in the comments.

    This is the forum thread about addressables scene loading.
     
  5. NatureRaph

    NatureRaph

    Joined:
    Aug 13, 2021
    Posts:
    8
    So everyone wanna doing the same:
    Just Disable Scene Management on NetworkManager and let all Scenes load you want on Host/Server and Client Side. The Player will spawn normally and for the Sync of prefabs, I recommend checking this out: https://docs-multiplayer.unity3d.com/netcode/1.0.0/basics/scenemanagement/custom-management/. So basically you have to do override the Hash from the NetworkObject for every inScenePlaced Prefab, but thats really it. Hope I can help with that. If somebody has further questions, feel free to ask.