[FishNet] Can't unload/close scene on clients

Hi, I'm trying to unload/close a scene on all clients when the server Host ends the game, but no matter what I do, the scene simply doesn't unload/close...

Both the Host and the other Clients are in the GameLobby scene that was loaded globally

SceneLoadData sld = new SceneLoadData(sGameLobby.name);
sld.PreferredActiveScene = new PreferredScene(new SceneLookupData(sGameLobby.name));

NetworkConnection clientConnection = InstanceFinder.ClientManager.Connection;
InstanceFinder.SceneManager.LoadGlobalScenes(sld);

Then I the host quicks the game and unloads the global scene for all clients too.

public IEnumerator QuitLobby() {

    if (InstanceFinder.IsHostStarted) {      // if it's the host quitting the game then the game needs to be closed to all other clients too
        // Unload Game lobby from network
        SceneUnloadData sud = new SceneUnloadData(sGameLobby.name);
        InstanceFinder.SceneManager.UnloadGlobalScenes(sud);           
    }
    else {
        // it's it's just the client quitting, disconnect that client from the scene.
        SceneUnloadData sud = new SceneUnloadData(sGameLobby.name);
        InstanceFinder.SceneManager.UnloadConnectionScenes(InstanceFinder.ClientManager.Connection, sud);
        //yield return sGameLobby.Close();

    }

    // Disconnect Host / player
    NetworkConnectionManager.Instance.DisconnectFromNetwork();

    // Wait for Host/Player to be fully disconnected
    while(InstanceFinder.IsServerStarted) {
        yield return null;
    }

    while(InstanceFinder.IsClientStarted) {
        yield return null;
    }

    // Load MainMenuIntro and wait for it to load
    yield return sMainMenuIntro.Open().Focus(sMainMenuIntro);

}

When I work with the host, the host clients correctly and the GameLobby scene is correctly closed.
But all other clients still stay on the scene and it's not unloaded for them.

I have already looked through the documentation and examples but still can't find the answer to this problem.
Tried all sorts of ways to close the scene for the clients but the scene simply doesn't close.

Feel that something as simple as closing a scene should be straight forward but it simply doesn't work :(

My game is not complex and all players will always be on the same scene (and I don't use spawned or owned objects)

Would anyone be able to help?

Many thanks in advance.

Was able to unload the scene using unities own async scene unload (using unity's ScneneManager)

The SceneManager for FN only handles network scenes. If a client or server is not networked or offline then the load/unloads cannot go through.

We have a DefaultScene component which shows one way of loading into a scene once connected, and returning to an 'offline' scene when not.

Thanks @Punfish

1 Like