Search Unity

Third Party PhotonNetwork.LoadLevel("Loading") - Screen freezes while its loading

Discussion in 'Multiplayer' started by JD_FVTC, Oct 27, 2020.

  1. JD_FVTC

    JD_FVTC

    Joined:
    Oct 20, 2017
    Posts:
    54
    Is there a better way to Load my scenes with PhotonNetwork so they don't lock up while loading the next scene?

    Code (CSharp):
    1.  
    2.     public void LeaveAndLoadHomeScene()
    3.     {
    4.         if (managepathtonextscene != null)
    5.         {
    6.             managepathtonextscene.scenetoLoad = "HomeScene";
    7.         }
    8.  
    9.         PhotonNetwork.LeaveRoom();
    10.     }
    11.     public void LeaveAndJoinPortblaster_Solo()
    12.     {
    13.         managepathtonextscene.scenetoLoad = "PortScanner";
    14.         PhotonNetwork.LeaveRoom();
    15.     }
    16.  
    17.     #region Photon Call back Methods
    18.    
    19.     public override void OnLeftRoom()
    20.     {
    21.         PhotonNetwork.Disconnect();
    22.     }
    23.     public override void OnDisconnected(DisconnectCause cause)
    24.     {
    25.         if (managepathtonextscene != null)
    26.         {
    27.             if (managepathtonextscene.scenetoLoad == "HomeScene")
    28.             {
    29.                 PhotonNetwork.LoadLevel("HomeScene");
    30.             }
    31.             else
    32.             {
    33.              
    34.                 PhotonNetwork.LoadLevel("Loading");
    35.             }
    36.         }
    37.         else
    38.         {
    39.             PhotonNetwork.LoadLevel("HomeScene");
    40.         }
    41.     }
     
  2. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,735
    Is the problem actually down to Photon, or is it just that you have a lot of stuff initialising after the map is loaded?

    I had to overcome a similar issue myself and I needed to implement a system where the scene geometry and mobs/npc game objects are either preloaded (with data describing which scene they are in) when the game first loads and then are activated/deactivated when each scene is loaded or if not included in that pool they are instantiated using a scene specific dataset, over the course of a number of frames once the map has loaded.

    The reason for the two different data sets, is because some things didn't suit being instantiated across a number of frames, so having them pre-instantiated in pool meant that they could be quickly activated on scene load without causing any hiccups.

    Yours may not be the same problem, but I'm not aware of Photon having any issues with loading scenes in itself.
     
    JD_FVTC likes this.
  3. kopf

    kopf

    Joined:
    Sep 1, 2017
    Posts:
    11
    Maybe not your issue, but can you even call PhotonNetwork.LoadLevel after you've disconnected?
     
    tobiass likes this.
  4. JD_FVTC

    JD_FVTC

    Joined:
    Oct 20, 2017
    Posts:
    54
    yes that works it loads level just freezes screen while it loads