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

Is there a better way to Load my scenes with PhotonNetwork so they don’t lock up while loading the next scene?

    public void LeaveAndLoadHomeScene()
    {
        if (managepathtonextscene != null)
        {
            managepathtonextscene.scenetoLoad = "HomeScene";
        }

        PhotonNetwork.LeaveRoom();
    }
    public void LeaveAndJoinPortblaster_Solo()
    {
        managepathtonextscene.scenetoLoad = "PortScanner";
        PhotonNetwork.LeaveRoom();
    }

    #region Photon Call back Methods
    
    public override void OnLeftRoom()
    {
        PhotonNetwork.Disconnect();
    }
    public override void OnDisconnected(DisconnectCause cause)
    {
        if (managepathtonextscene != null)
        {
            if (managepathtonextscene.scenetoLoad == "HomeScene")
            {
                PhotonNetwork.LoadLevel("HomeScene");
            }
            else
            {
              
                PhotonNetwork.LoadLevel("Loading");
            }
        }
        else
        {
            PhotonNetwork.LoadLevel("HomeScene");
        }
    }

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.

1 Like

Maybe not your issue, but can you even call PhotonNetwork.LoadLevel after you’ve disconnected?

1 Like

yes that works it loads level just freezes screen while it loads