b15 b15 - 3 months ago 10
Android Question

How to get the current player's participant id in Xamarin

Using google games services, how do I get the participant id of the 'current player' using Xamarin? In Java, it's simply

room.getParticipantId(Games.Players.getCurrentPlayerId(mGoogleApiClient));


But I can't find the equivalent in C# with the Xamarin google games component.

Answer

Where client is a GoogleApiClient that has the GamesClass.API added and the GamesClass.ScopeGames added to it:

if (client.IsConnected)
{
    var player = GamesClass.Players.GetCurrentPlayer(client);
    Console.WriteLine(player.PlayerId);
    Console.WriteLine(player.DisplayName);
}
Comments