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

Async Scene Load With Network Manager

Discussion in 'Multiplayer' started by Chris-Trueman, Jan 21, 2016.

  1. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    1,260
    I was wondering if there is a way to get the Network Manager to load the scene async? Or is this something I would need to code myself and bypass the Network Manager and basically write my own?
     
  2. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    1,260
    I found out that the NetworkManager already loads the scenes async looking at the source on Bitbucket. So I needed to override some functions to get the scene fading and a loading screen working.

    Some suggestions to make it a little easier to get scene fading/loading screens working without much hassle is to have the ability to override ClientSceneChange and access to the AsyncOperation that gets used when loading.
     
    RemDust likes this.
  3. RemDust

    RemDust

    Joined:
    Aug 28, 2015
    Posts:
    431
    Any chance to know how you implemented it man ? :)
     
  4. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    1,260
    I must have changed the code a while back. I now use a scene fade manager that fades the scene out then loads the next scene and then fades the new scene back in.

    I use uGUI to have an image overlaid on the screen, script that sets DontDestroyOnLoad on it. The script fades the overlay image in, tells the network manager to load a new scene, uses the new scene manager system to get the SceneLoaded event and then once the scene is loaded fades the overlay image out.
     
  5. RemDust

    RemDust

    Joined:
    Aug 28, 2015
    Posts:
    431
    Thanks for answering dude :
    I was more talking about the async operation side of things.

    I'd like to load the scene for each client but wait for the load to be completed everywhere before actually change the scene (via .allowsceneactivation) :)
     
  6. donnysobonny

    donnysobonny

    Joined:
    Jan 24, 2013
    Posts:
    220
    That's a fairly complex requirement, one that you wouldn't be able to achieve with unet alone. At minimum, you could implement this yourself by doing something like:
    • the server-side knows how many clients are loading the scene
    • once a client loads the scene successfully, the client notifies the server
    • once the server has received this notification from all clients (based on how many clients have notified the server against how many clients there are in total) the server notifies all clients that everyone is ready
    Hopefully this helps!