Last active
April 21, 2020 11:17
-
-
Save giacomelli/c8bff996de4473c201f010b17d42fd2b to your computer and use it in GitHub Desktop.
Google Play Games Plugin for Unity:Tips & Tricks (http://diegogiacomelli.com.br/google-play-games-plugin-for-unity-tips-and-tricks)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using GooglePlayGames; | |
using GooglePlayGames.BasicApi; | |
using UnityEngine; | |
public class AchievementsController : MonoBehaviour | |
{ | |
void Start() | |
{ | |
var config = new PlayGamesClientConfiguration.Builder().Build(); | |
PlayGamesPlatform.InitializeInstance(config); | |
PlayGamesPlatform.DebugLogEnabled = true; | |
PlayGamesPlatform.Activate(); | |
// Authenticate and register a ProcessAuthentication callback | |
// This call needs to be made before we can proceed to other calls in the Social API | |
Social.localUser.Authenticate(ProcessAuthentication); | |
} | |
// This function gets called when Authenticate completes | |
// Note that if the operation is successful, Social.localUser will contain data from the server. | |
void ProcessAuthentication(bool success) | |
{ | |
if (success) | |
{ | |
Debug.Log("Authenticated."); | |
PlayGamesPlatform.Instance.ShowAchievementsUI(); | |
} | |
else | |
Debug.Log("Failed to authenticate"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment