For the complete documentation index, see llms.txt. This page is also available as Markdown.

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

GetJoinedLobbies() - https://docs.unity.com/lobby/get-joined-lobbies.html

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

RemovePlayerFromLobby() - https://docs.unity.com/lobby/leave-a-lobby.html

    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);
        }
    }

LoadPlayerData() - https://docs.unity.com/cloud-save/cloud-save-usage.html#Fetching_items

SavePlayerData() - https://docs.unity.com/cloud-save/cloud-save-usage.html#Save_an_item

UpdatePlayerData() - https://docs.unity.com/lobby/update-player-data.html

Last updated