Easy Code For Vivox
  • Introduction
    • Official Links
    • Getting Started
      • Wheres The Code
      • Setup EasyCode in My Project
    • Setup Demo Scenes
      • Vivox Developer Portal
      • Unity Gaming Services (UGS) Dashboard
    • Things To Consider
    • FAQ
  • Development Info
    • Design Decisions
    • Release Notes
      • v2.0
      • v1.3
      • v1.2
      • v1.1
      • Template
    • Not Supported
  • Easy Code For Vivox
    • How do I setup EasyCode?
      • Setup Your Credentials
    • How do I do this in EasyCode?
      • Login / Logout
        • Login Properties
        • SetTransmissionMode
        • Login Events
      • Join / Leave Channel
        • Audio Channel
          • Audio Channel Events
        • Text Channel
          • Text Channel Events
        • Channel Events
      • Send Messages
        • Message Events
      • Mute / Unmute
        • Mute / Unmute Events
      • Subscribe to User Events
      • Volume / Audio Settings
        • Audio Device Events
      • Text To Speech ( TTS )
        • TTS Events
    • Vivox Access Tokens
      • Unity Cloud Code
    • Supported Vivox Events
      • Callback Methods
    • Folder Structure / Info
      • / Demo Scenes /
      • / Documentation /
      • / Examples /
      • / Plugins /
      • / Resources /
      • / Scripts /
      • / Settings /
    • Common Errors
  • API Info
    • EasySession.cs
    • EasyManager.cs
      • Main Methods
      • Vivox Event Callbacks
    • Easy3DPositional.cs
    • EasyVivoxUtilities.cs
    • EasySettings.cs
    • Extension Methods
      • EasySIPExtensions.cs
      • GameObjectExtensions.cs
      • TTSMessageExtensions.cs
      • UIExtensions.cs
      • VivoxExtensions.cs
      • EasyDebug.cs
    • EasyEvents.cs
  • Dependency Injection
    • Zenject vs Extenject
    • Install Dependencies
    • Inject Classes
  • Dynamic Events
    • Dynamic Events
    • Tests
    • Gotchas
    • Dynamic Async Events
      • Dont Do
    • Event Examples
  • Related Info
    • How do I do this in Vivox?
      • Conference Chat
    • Pre-Processor Directives
    • How to set iOS Info.plist for Unity?
    • Unity Gaming Services
  • The Future
    • Roadmap
    • Todo / Notes / Changelog
Powered by GitBook
On this page
  • GetJoinedLobbies() - https://docs.unity.com/lobby/get-joined-lobbies.html
  • RemovePlayerFromLobby() - https://docs.unity.com/lobby/leave-a-lobby.html
  • 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

Was this helpful?

  1. Related Info

Unity Gaming Services

PreviousHow to set iOS Info.plist for Unity?NextRoadmap

Last updated 2 years ago

Was this helpful?

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() -

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

RemovePlayerFromLobby() -

    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);
        }
    }
    public async Task LoadPlayerData()
    {
        try
        {
            Dictionary<string, string> savedData = await CloudSaveService.Instance.Data.LoadAsync(new HashSet<string> { "key" });

            Debug.Log("Done: " + savedData["key"]);
        }
        catch (LobbyServiceException e)
        {
            Debug.Log(e);
        }
    }
    public async Task SavePlayerData()
    {
        try
        {
            var data = new Dictionary<string, object> { { "key", "someValue" } };
            await CloudSaveService.Instance.Data.ForceSaveAsync(data);
        }
        catch (Exception e)
        {
            Debug.Log(e);
        }
    }
    public async Task UpdatePlayerData()
    {
        try
        {
            UpdatePlayerOptions options = new UpdatePlayerOptions();

            options.Data = new Dictionary<string, PlayerDataObject>()
            {
                {
                    "existing data key", new PlayerDataObject(
                        visibility: PlayerDataObject.VisibilityOptions.Private,
                        value: "updated data value")
                },
                {
                    "new data key", new PlayerDataObject(
                        visibility: PlayerDataObject.VisibilityOptions.Public,
                        value: "new data value")
                }
            };

            //Ensure you sign-in before calling Authentication Instance
            //See IAuthenticationService interface
            string playerId = AuthenticationService.Instance.PlayerId;

            var lobby = await LobbyService.Instance.UpdatePlayerAsync("lobbyId", playerId, options);

        }
        catch (LobbyServiceException e)
        {
            Debug.Log(e);
        }
    }

LoadPlayerData() -

SavePlayerData() -

UpdatePlayerData() -

https://docs.unity.com/lobby/get-joined-lobbies.html
https://docs.unity.com/lobby/leave-a-lobby.html
https://docs.unity.com/cloud-save/cloud-save-usage.html#Fetching_items
https://docs.unity.com/cloud-save/cloud-save-usage.html#Save_an_item
https://docs.unity.com/lobby/update-player-data.html