[FishNet] Scene manager callback events triggering twice in a row?!

Hi, I was hoping to use the ScneneManager callback events in order to implement a loading screen process, however, once I started to test the event, I saw that the events were being triggered twice in a row.

What is wrong with it and how can I fix this?

I also noticed that the whole queueStrart->loadStart->loadEnd->queueEnd process is being triggered twice: once AsServer=true and another has false. I'm assuming that somehow the process is executed for the server part or the networking and then done again for the client part.

Since this is a Loading screen and only the "client part" really needs to process it, how can I ensure only the client part processes the events?

I made these tests with a Host client (connected as server+client)

Many thanks in advance.

9913776--1432983--upload_2024-6-28_14-37-26.png

As you assumed this occurs when running as clientHost because both the server and clients get the callbacks. This is intended so you can perform different actions if server vs client.

You can simply exit the method and not do anything if asServer is true.

[quote=“Punfish”, post:2, topic: 951457]
You can simply exit the method and not do anything if asServer is true.
[/quote]

How can I do that inside the OnQueueStart and OnQueueEnded?


Ah you're using that, which does not specify server or client because it would fire once even as host since the queue is still running when client begins loading.

You probably just want to use the load start callback to begin showing loading screen if not asServer, and hide OnQueueEnd

And then on every LoadStart check if it's already open and not open again, correct?

How can I make sure the load process doesn't start before the loading screen is ON

If you hook into this callback you can show the loading screen before the scene actually starts to load
https://firstgeargames.com/FishNet/api/api/FishNet.Managing.Scened.SceneManager.html#FishNet_Managing_Scened_SceneManager_OnLoadStart

Then you can simply do something like...

if (loadingScreenActive) return;

ShowLoadingScreen();

I see, so the OnLoadStarted will execute fully before the load process actually starts.

Got it
Thanks @Punfish

1 Like


Correct! There are LoadEnd callbacks, and a few others as well. If you want even more control you can implement our SceneProcessor class https://fish-networking.gitbook.io/docs/manual/guides/scene-management/custom-scene-processors