0
\$\begingroup\$

I am making an android game in Unity (C#), in which I've used the Google's official plugin for Google Play Services. My question is how to detect that a player has clicked on sign out button on Google's UI

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

Well, in Unity you can check GPGS and Game Center login status via Social.localUser.authenticated. This will return a bool value that indicates either the user is logged in or not. true for logged in and false for logged out.

void PrintUserStatus()
{
    if (Social.localUser.authenticated)
        print("Player is logged in");
    else
        print("Player is not logged in");
}
\$\endgroup\$
6
  • \$\begingroup\$ So, are you suggesting I put this inside my Update function and check every single frame ? I had this way in my mind, but I was hoping some way like an event or something which rises as soon as the sign out is done. \$\endgroup\$
    – Ashish
    Feb 9, 2016 at 13:09
  • \$\begingroup\$ In Update? not at all. Why don't you just check before any operation? \$\endgroup\$ Feb 9, 2016 at 13:13
  • \$\begingroup\$ Actually I'm showing the current user name text on my main UI and I wanted to make it convert to user name (Local) when signed out, if I put this check before any operation then this text field will not update till user interacts, which is not much appreciated. \$\endgroup\$
    – Ashish
    Feb 9, 2016 at 13:53
  • \$\begingroup\$ I can suggest an alternative solution, that is you can put a button for sign-out explicitly. So from there you can cover at least 50% of your problem \$\endgroup\$ Feb 10, 2016 at 9:02
  • \$\begingroup\$ I have an explicit button already in my UI, but I was thinking of getting rid of this case. By the way, what will be the impact on performance if I put the Social.localUser.authenicated check in update method ? If it doesn't makes much of an effect I'm willing to go with approach. \$\endgroup\$
    – Ashish
    Feb 10, 2016 at 22:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .