Documentation
Ask or search…
K
Links

Exit the current Room

Getting out of the room, back to the lobby
If you are the host and leave the lobby, one of the remaining clients will automatically become the new host.
public async void ExitCurrentLobby()
{
if (CurrentLobby == null) return;
/* Remove this player out of this lobby */
if (CurrentLobby.Players.Count > 1)
{
await LobbyService.Instance.RemovePlayerAsync(CurrentLobby.Id, AuthenticationService.Instance.PlayerId);
}
else
{
await LobbyService.Instance.DeleteLobbyAsync(CurrentLobby.Id);
}
isLobbyHost = false;
isSetInitPlayerDataObject = false;
CurrentLobby = null;
NetworkManager.Singleton.Shutdown();
if(MenuSceneManager.Instance is not null)
MenuSceneManager.Instance.UpdateStatusText();
}
public void OnApplicationQuit()
{
ExitCurrentLobby();
}