Google Play Services

Hey there everyone! I am just wondering how to use Google Play Services? I got the 3rd party plug that unity recommended (GooglePlayGames) but I have no clue really on how to implement it. I did the steps wit hteh APPID and everything, but not exactly sure on how /where to implement it. Tried adding some of the code but got lost quick.

Thanks in advance

Here is the method I used not too long ago. Should check for updated version of the stuff I linked to, but should be working no problem still. Let’s you integrate AdMob as well. If you don’t need that just skip to parts about the play services.

Good luck!

EDIT: oh PS it doesn’t go into a lot of detail in the actual implementation of said plugins with you surely unique game setup. It really is just getting them in there (imported) and set up right. To do the actual scripting calls you need to do with play services and/or admob, then you will find helpful info on each of the readme files you see in the respective pages where I link to download those packages. You do have to read carefully but they describe how it is done there vaguely. If you run into problems still, check some examples that are available.

" and then configure your project to send calls to the plugin when you unlock achievements, and set high scores and such. You could take this further but that is as much as I needed in my project." Right there is where I get lost. I can not figure that part out. As I said I already have the playgames imported, i pressed setupo - android, entered my app id, it did some things and now I need to set up the calls.

Ok well. Let us see here, you did the “setup” and entered your info, so you must already have an acct and stuff ready, so that means part of the battle is over lol. Now you need to put this in your script thats going to handle loading and hiding ads. Start at the top of what will be your ad handler script with this:

using GooglePlayGames;
using UnityEngine.SocialPlatforms;

and then say in the Start() method do this:

PlayGamesPlatform.Activate();

and once thats done, you must authenticate you user (this can take some amount of time on mobile networks - possible over a minute, so start near load time of your game so its ready when game scenes start getting loaded in, or before player can do anything) doing something like this:

// authenticate user:
Social.localUser.Authenticate((bool success) => {
// handle success or failure
if(success) // the login completed successfully
{
LoggedIntoPlayServices = true; // some bool to let us know later were logged in ok before trying to unlock achievements or send scores to a leaderboard
}
});

and then even further along the code chain you need to maybe unlock an achievement:

// unlock achievement (achievement ID "Cfjewijawiu_QA")
Social.ReportProgress("Cfjewijawiu_QA", 100.0f, (bool success) => {
// handle success or failure
if(success) // we have successfully sent our acheivement to the play servers
{
// maybe we should show some info in game to alert the player (besides the toaster pop up from the plugin - which is flakey)
}
});

or maybe we need to post to a leaderboard:

// post score 12345 to leaderboard ID "Cfji293fjsie_QA")
Social.ReportScore(12345, "Cfji293fjsie_QA", (bool success) => {
// handle success or failure
if(success)
{
// might do something like...
if(NeverEnteredScoreBefore)
{
GivePlayerCookie(); // some sort of interaction after loading the scores... perhaps show the leader boards themselves?
}
}
});

and you will see many more examples on the readme’s of those plugins!

Good Luck… again! lol