How to get scene load progress when using photonnetwork.loadlevel

Hi,

I use photonnetwork.loadlevel to load my scenes and I have it set up so that when the master client switches the other players in the room automatically switch as well.

Usually in unity to do a progress bar for loading a scene you would use async load and then check operation progress to see how far you had got in order to update your loading progress.

With photonetwork.loadlevel I'm not aware of how I would get the scene progress as there doesn't appear to be any way of checking load progress?
I'm aware photon doesn't have an async load so how do I go about getting the scene load progress for the master and the various joined hosts so they can be presented with some time line type information on how long they will need to wait for the scene to load?

Best Answer

Answers

  • OK, thankyou, I suspected it wasn't really possible, I'll wait and see what you guys come up with.
  • S_Oliver
    S_Oliver ✭✭✭
    Hi,did you find a good Solution ?
  • Hi @S_Oliver,

    PhotonNetwork.LoadLevelAsync() has been added in PUN version 1.90.
  • S_Oliver
    S_Oliver ✭✭✭
    edited May 2018
    Thanks @Christian_Simon , already written my own solution but this is awsome,gonna check this out soon.Thanks!
    EDIT: When you Update the Docs to 1.9 ?
  • Hello sir,
    I have same problem. Just I want to use "CreateOrJoinRoom" method but I don't want to load scene. Becuse I developed an async loader. I running progressbar for this. Last times do you have an upgrade for this?
  • Hi @S_Oliver,

    PhotonNetwork.LoadLevelAsync() has been added in PUN version 1.90.

    This funcion is not in PUN V2. How can we handle async loading then?
  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @kureysalp,

    PhotonNetwork.LoadLevel is always async by design and by default in PUN2.
    We will add this to the migration notes.
  • So how can I use this with IEnumerator like while(async.progress<1)

    Because this function is void, has no return type. I can't make a loading screen with it.
  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @kureysalp,

    Use PhotonNetwork.LevelLoadingProgress.
  • kureysalp
    kureysalp
    edited September 2019
    @JohnTube
    IEnumerator LoadLevelAsync()
        {
            PhotonNetwork.LoadLevel("Network Test");
    
            while (PhotonNetwork.LevelLoadingProgress < 1)
            {
                loadAmountText.text = "Loading: %" + (int)(PhotonNetwork.LevelLoadingProgress * 100);
                //loadAmount = async.progress;
                progressBar.fillAmount = PhotonNetwork.LevelLoadingProgress;
                yield return new WaitForEndOfFrame();
            }     
        }

    I tried but scene loaded instantly.
  • Oh, I found the problem. This code is working very well.
  • But I have a question. Normally "PhotonNetwork.LoadLevel()" must be called from master client and others must have PhotonNetwork.AutomaticallySyncScene true. But When I use numerator for loading screen, in master client okay no problem. But clients loads the scene instantly and their PhotonNetwork.LevelLoadingProgress is not increasing. This loading screen thing is confusing with photon and there is no tutorial for it. I should ask you how can we handle it?
  • jeanfabre
    jeanfabre mod
    edited September 2019
    Hi,

    It all works fine here, I do get the progress value when pun is loading a scene to synchronize and I am not the master.

    the scene loading are always asynchronous, so when you say it loads instantly, it's likely that the scene is very small.

    I tested with the pun basic tutorial and I could catch the loading as more player joined, though of course I caught it only in one frame, because the scene is small:
    if (PhotonNetwork.LevelLoadingProgress > 0 && PhotonNetwork.LevelLoadingProgress < 1)
    			{
    				Debug.Log(PhotonNetwork.LevelLoadingProgress);
    			}
    
    and I got this:




    Bye,

    Jean
  • hi @jeanfabre .... what i have noticed that the loading bar shows only 0.9 that means it doesnot show to progres from 0.0 to 0.8 and it directly goes to 0.9.Hahaha!!!...
  • Eristen
    Eristen
    edited March 2021
    Likewise. PhotonNetwork.LevelLoadingProgress only ever returns 0 or 0.9. Not a very useful loading information...

    edit: okay so I looked around and this is not actually a Photon issue, photon is using Unity's API for loading progress so it's on Unity's end.
  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @Eristen,

    Thank you for choosing Photon!

    This is on Unity yes.

    Here is a good blog post about this.
  • I can't seem to edit my previous answer so I will just spam here if I can.

    The Unity APi works as well, but not in the editor. In build it shows proper loading percentage but in the editor it only shows 0 and 0.9. No fret.