Unity Gaming Services

These are code examples are copied from some of Unity's Gaming Services. I use these example methods throughout EasyCode docs especially when describing use cases for Dynamic Async events

    public async Task GetJoinedLobbies()
    {
        try
        {
            var lobbyIds = await LobbyService.Instance.GetJoinedLobbiesAsync();
        }
        catch (LobbyServiceException e)
        {
            Debug.Log(e);
        }
    }

    public async Task RemovePlayerFromLobby()
    {
        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);
        }
    }

Last updated

Was this helpful?