PhotonNetwork.LoadLevelAsync removed in PUN 2?

I saw from the PUN 1.9 release notes that LoadLevelAsync was added, why has this not been included with PUN2? Is there another way to accomplish this with PUN 2?

Thanks in advance!

Comments

  • Would really love to get an answer on this. Would be really helpful.

    Thanks in advance!
  • To be clear, actually PUN2 has removed a wrapper around SceneManager.LoadScene (ie the non-asynchronous one has been removed). If you need to load a scene synchronously, you can simply call it via the SceneManager, directly. Below is the code for PhotonNetwork.LoadLevel...
    PUN1
        public static void LoadLevel(string levelName)
    {
    if (PhotonNetwork.automaticallySyncScene) {
    networkingPeer.SetLevelInPropsIfSynced (levelName);
    }

    PhotonNetwork.isMessageQueueRunning = false;
    networkingPeer.loadingLevelAndPausedNetwork = true;
    SceneManager.LoadScene(levelName);
    }


    public static AsyncOperation LoadLevelAsync(string levelName)
    {
    if (PhotonNetwork.automaticallySyncScene) {
    networkingPeer.SetLevelInPropsIfSynced (levelName,true);
    }

    PhotonNetwork.isMessageQueueRunning = false;
    networkingPeer.loadingLevelAndPausedNetwork = true;
    return SceneManager.LoadSceneAsync(levelName,LoadSceneMode.Single);
    }
    PUN2
            public static void LoadLevel(int levelNumber)
    {
    if (PhotonNetwork.AutomaticallySyncScene)
    {
    SetLevelInPropsIfSynced(levelNumber);
    }

    PhotonNetwork.IsMessageQueueRunning = false;
    loadingLevelAndPausedNetwork = true;
    _AsyncLevelLoadingOperation = SceneManager.LoadSceneAsync(levelNumber,LoadSceneMode.Single);
    }

    public static void LoadLevel(string levelName)
    {
    if (PhotonNetwork.AutomaticallySyncScene)
    {
    SetLevelInPropsIfSynced(levelName);
    }

    //PhotonNetwork.IsMessageQueueRunning = false;
    //loadingLevelAndPausedNetwork = true;
    _AsyncLevelLoadingOperation = SceneManager.LoadSceneAsync(levelName, LoadSceneMode.Single);
    }
    As you can see, PUN2 simply provides overloaded LoadLevel options, both of which call SceneManager.LoadSceneAsync. So, despite the naming convention merger, I'd say your concerns or alleviated.

  • I posted a response that seems to have been placed in some holding awaiting approval... who knows...
    Anyway, PUN2 actually removed the wrapper around SceneManager.LoadScene. Both overloads for PhotonNetwork.LoadLevel provided result in calling SceneManager.LoadSceneAsync.
  • Hmm interesting so your saying by default PhotonNetwork.LoadLevel loads asynchronously?

    Also not sure what you mean about the awaiting approval. Do you mean for this thread or in regards to PhotonNetwork.LoadSceneAsync? If it's the latter mind posting a link?

    Thanks in advance!
  • Regarding the awaiting of approval - I had typed up a much nicer response post in this discussion, and then I edited it. When I saved the edit, it said my post needs to be approved - by who, and for what purpose, I have no idea... I don't know where my post is, or if it will ever show up.

    As for the conclusion of my post, yes, PhotonNetwork.LoadLevel loads asynchronously.
  • Ah got it. Thanks so much!
Sign In or Register to comment.