How to get scene load progress when using photonnetwork.loadlevel
The whole answer can be found below.
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).
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
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
OK, thankyou, I suspected it wasn't really possible, I'll wait and see what you guys come up with.
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.
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?
@[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?
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.
Hi @kureysalp,
Use PhotonNetwork.LevelLoadingProgress
.
@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?
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!!!...
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.
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.
Back to top