1. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  2. Unity 2017.2 beta is now available for download.
    Dismiss Notice
  3. Unity 2017.1 is now released.
    Dismiss Notice
  4. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  5. Reddit AMA with Adam Myhill on Cinemachine, Thurs July 27 - 10AM PT. More info.
    Dismiss Notice
  6. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  7. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice

Unity Multiplayer Async Scene Load With Network Manager

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

  1. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    306
    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:
    306
    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:
    223
    Any chance to know how you implemented it man ? :)
     
  4. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    306
    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:
    223
    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:
    197
    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!