退出大厅
Learn how players can leave a lobby and what happens when they exit.
阅读时间1 分钟最后更新于 1 个月前
当玩家退出大厅时,其玩家 ID 会从玩家列表中移除。如果厅主退出大厅,系统会随机选择大厅中的另一名玩家作为厅主。厅主还能够从大厅中移除其他玩家。这两种情况下都使用相同的 RemovePlayerAsync API 调用,厅主只需指定其他玩家的玩家 ID 而不是自己的 ID 即可。当大厅中的最后一名玩家退出时,大厅便会被自动删除。 以下代码示例展示了如何从大厅中移除玩家: C#
try{ //Ensure you sign-in before calling Authentication Instance //See IAuthenticationService interface string playerId = AuthenticationService.Instance.PlayerId; await LobbyService.Instance.RemovePlayerAsync("lobbyId", playerId);}catch (LobbyServiceException e){ Debug.Log(e);}