简体   繁体   中英

OnClientExitRoom function is called twice

I'm using NetworkRoomManager and NetworkDiscovery and when a player exits a room scene I call the NetworkManager.singleton.StopClient() in networkdiscoveryhud then you will found out that its calling the OnClientExitRoom function in networkroomplayerext script twice.

Or I should not use NetworkManager.singleton.StopClient() when client exit a room scene? Below is my script for client or server exiting a room.

public void StopHost()
{
    if (NetworkServer.active && NetworkClient.isConnected)
    {
        NetworkManager.singleton.StopHost();
    }
    else if (NetworkClient.isConnected)
    {
        NetworkManager.singleton.StopClient();
    }
    else if (NetworkServer.active)
    {
        NetworkManager.singleton.StopServer();
    }

    networkDiscovery.StopDiscovery();
}

I recommend Lobby and Worlds. It's much more flexible than NetworkRoomManager and has a ton of built in features. More info on it here. https://trello.com/c/0jT4kZ6O

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM