Photon and Loading Screens

Options
Hi everyone, I'm bit confused on how to create a simple loading screen with Photon.

I have the PhotonNetwork.automaticallySyncScene = true so all the clients in the same room join the same level selected by the master client.

I understand that I must set isMessageQueueRunning = false so PUN won't dispatch incoming messages but how do I know that the level itself finished loading? In normal terms I would use LoadLevelAsync() but I have read that PUN does not make use of that method.

The process that Im taking is this:
1 - Create or join room
2 - OnCreateRoom() I use the PhotonNetwork.LoadLevel() to enter the level
3 - Loading Screen Scene - finishes when the level selected above finished loading -> The problem
4 - Spawn Characters on Awake ( ... )

Am I making a big confusion with this or what? :D
Can some one enlighten this matter?

Thank you. :)

Comments

  • Plain
    Options
    facing the same problem here :neutral: did you perhaps already have solution to this problem?
  • MrSuicide
    Options
    We solved this issue by disabling PhotonNetwork.automaticallySyncScene entirely and doing the following (A level load manager handles this):

    1. Disable message queue
    2. Run async operation SceneManager.LoadSceneAsync(newScene)
    3. OnSceneLoaded() change the active scene to the new scene
    4. Run async operation SceneManager.UnloadSceneAsync(oldScene)
    5. Enable message queue
    6. OnSceneUnloaded() destroy the loading screen UI canvas
  • BadTowers
    Options
    Wanted to toss in my two cents to this thread. I solved it by tracing how the levels load synchronously. We see it eventually calls a function LoadLevelIfSynced(). Inside, it gets object sceneId = PhotonNetwork.CurrentRoom.CustomProperties[CurrentSceneProperty];, where internal const string CurrentSceneProperty = "curScn";
    1) Implement OnRoomPropertiesUpdate.
    2) Check for this property and see if it's different that then "before" scene name.
    3) If it is, I set LoadingLevel = true;
    4) In the Update() function, if LoadingLevel is true, then we show the loading screen (or add animations to the loading screen or whatever you want).