How to get scene load progress when using photonnetwork.loadlevel

The whole answer can be found below.

Please note: The Photon forum is closed permanently. After many dedicated years of service we have made the decision to retire our forum and switch to read-only: we've saved the best to last! And we offer you support through these channels:

Try Our
Documentation

Please check if you can find an answer in our extensive documentation on PUN.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Read More on
Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

How to get scene load progress when using photonnetwork.loadlevel

Ash68
2017-08-08 14:07:41

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?

Comments

jeanfabre
2017-08-14 08:55:40

Hi,

you are right, currently PhotonNetwork.loadLevel is not asynch and so no progress bar can be shown.

We have a task for our next update to study support for asynch level loading, but it's still a work in progress because of several issues due to the nature of asynch loading, and how to make sure everything starts properly, what if one device takes a lot longer to load a scene, what should the other devices do while waiting yet their level is already loaded...

Currently, the best way is to implement level loading manually when using asynch options to control properly, via an RPC when everyone can starts.

Bye,

Jean

Ash68
2017-08-16 10:55:11

OK, thankyou, I suspected it wasn't really possible, I'll wait and see what you guys come up with.

S_Oliver
2018-05-07 16:12:45

Hi,did you find a good Solution ?

[Deleted User]
2018-05-08 08:23:52

Hi @S_Oliver,

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

S_Oliver
2018-05-08 08:29:47

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 ?

ecanturk41
2018-09-14 17:47:51

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?

kureysalp
2019-09-17 16:30:35

@[Deleted User] wrote:

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
2019-09-17 20:26:27

Hi @kureysalp,

PhotonNetwork.LoadLevel is always async by design and by default in PUN2.
We will add this to the migration notes.

kureysalp
2019-09-17 21:07:07

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
2019-09-17 21:40:20

Hi @kureysalp,

Use PhotonNetwork.LevelLoadingProgress.

kureysalp
2019-09-17 23:10:02

@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.

kureysalp
2019-09-17 23:19:19

Oh, I found the problem. This code is working very well.

kureysalp
2019-09-18 02:09:15

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
2019-09-19 06:09:23

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

GarvGoel_77
2020-06-25 18:52:26

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
2021-03-06 17:34:32

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
2021-03-08 11:40:34

Hi @Eristen,

Thank you for choosing Photon!

This is on Unity yes.

Here is a good blog post about this.

Eristen
2021-03-21 16:57:27

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.

Back to top