1. We've introduced thread tags, search within a thread and similar thread search. Read more here.
    Dismiss Notice
  2. Learn how you'll soon be able to publish your games to China in four simple steps with Xiaomi. Sign up now for early access.
    Dismiss Notice
  3. Get further faster with the Unity Plus Accelerator Pack, free for new Unity Plus subscribers for a limited time. Click here for more details.
    Dismiss Notice
  4. We've released our first Timeline Experimental Preview, our new tool for creating cutscenes and more! To check it out click here.
    Dismiss Notice
  5. Unity 5.5 is now released.
    Dismiss Notice
  6. Check out all the fixes for 5.5 in patch releases 1 & 2.
    Dismiss Notice
  7. Unity 5.6 beta is now available for download.
    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:
    301
    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:
    301
    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:
    194
    Any chance to know how you implemented it man ? :)
     
  4. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    301
    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:
    194
    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:
    110
    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!