Event on client before Scene starts changing?

Is there a way to catch a “ServerChangeScene” event on the client before the Scene Change actually starts?
If this is not possible yet, will it be possible soon?

My failed attempts:

  • NetworkConnection.TransportReceive is not called for MsgType.Scene. I assume because it has a build in RegisterHandler.
  • NetworkClient.RegisterHandler for MsgType.Scene seems to overwrite the build in Handler “NetworkManager.OnClientSceneInternal” which is “internal”. So I’m assuming that if I overwrite it, I won’t be able to call “OnClientSceneInternal” anymore which would probably cause bugs to happen as it changes private/internal variables.
  • NetworkManager.OnServerSceneChanged happens after the scene has changed, which is too late.
  • ClientScene does not seems to have events?

I’m currently facing the exact same problem. I would like to do some processing right before changing scene on the client. Doing it on the server is no problem as there are enough method to override. But everything on the client seems to be marked as internal: RegisterHandler, OnClientSceneInternal, ClientChangeScene

Unity itself doesn’t have a way to detect a change of scene either at the level of the SceneManager.

Have you found a solution for this issue?

FYI, I found this Pull Request on the Unity Networking Bitbucket
https://bitbucket.org/Unity-Technologies/networking/pull-requests/11/networkmanager-make-clientchangescene/diff

I decided to actually jump on it, and make my own dll with the change provided meaning that ClientChangeScene would be public (or protected) virtual instead of internal.

We went with this:

Server sends a message to clients to prepare scene change.
All clients send acknowledge messages.
ServerChangeScene is called on server once all clients acknowledged or timed out.

This situation is more than a year old, and my current project is also struggling with this. Wanting to do pre/post scene load operations could be managed as suggested earlier. However, my project makes heavy use of LoadSceneMode.Additive scene loading. The NetworkManager loads everything as Single though. Furthermore, loading a scene anew always recreates its entire hierarchy (destroys old then instantiates again), which pretty much forces us to maintain a persistent model for the Lobby or game setup… we can’t just leave the Lobby Scene in its last state and simply return to it by removing all other scenes when SendReturnToLobby() is called. It’s unfortunate, but unless your multiplayer game setup very closely follows Network Lobby, you will likely need build your own Networking DLL. I’d love to see the very simple change of ClientChangeScene being made protected virtual, or giving us some flexibility in how we load scenes (particularly Lobby and Main).