InvalidCastException on (PlayGamesLocalUser)Social.localUser
Hello everyone!
I'm trying to use the Google Play Games Plugin for Unity, wich i downloaded from the URL: https://github.com/playgameservices/play-games-plugin-for-unity
In the same URL, we got all instruction about how to use. I followed them all, I even looked for several tutorials on the web, and also already updated to the latest version. But my problem persists.
I can't get a unique UserId.
According to the instructions, all we need to do is: PlayGamesClientConfiguration.Builder.RequestIdToken(); and ((PlayGamesLocalUser) Social.localUser).GetIdToken();
My problem is, the sample code just doesn't work! The cast fail with the following error in this line: InvalidCastException: Specified cast is not valid.
Here's my actual code:
PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().RequestIdToken().Build();
PlayGamesPlatform.InitializeInstance(config);
PlayGamesPlatform.DebugLogEnabled = true;
PlayGamesPlatform.Activate();
And I authenticate with:
Social.localUser.Authenticate(SignedIn);
private void SignedIn(bool sucess)
{
if (sucess)
{
Debug.Log("Sucess on Sign in!");
}
}
Authentication returns success but does not display that Google Play login popup during gameplay (testing on my phone).
Since I can't cast as in the manual, I tried several other ways, but nothing works! Already tryed:
Social.localUser.id
Social.Active.localUser.id
PlayGamesPlatform.Instance.localUser.id
PlayGamesPlatform.Instance.GetUserId()
I simply cannot get the authenticated user ID. And there are no errors in logcat...
My Unity Version is 2019.2.1f1 and my current GooglePlayGames plugin is 0.10.01. Can anybody help me?