Guest User

Untitled

a guest
Mar 9th, 2014
32
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using GooglePlayGames;
  2. using UnityEngine;
  3. using UnityEngine.SocialPlatforms;
  4. using System;
  5.  
  6. namespace HutongGames.PlayMaker.Actions
  7. {
  8.     [ActionCategory("Google Play")]
  9.     [Tooltip("Is the user logged in. If they are it will fill in username and userID")]
  10.     public class IsLoggedIn : FsmStateAction
  11.     {
  12.         [RequiredField]
  13.         [UIHint(UIHint.Variable)]
  14.         public FsmBool isLoggedIn;
  15.         [UIHint(UIHint.Variable)]
  16.         public FsmString username;
  17.         [UIHint(UIHint.Variable)]
  18.         public FsmString userID;
  19.  
  20.         public override void OnEnter()
  21.         {
  22. #if !UNITY_EDITOR && (UNITY_IOS || UNITY_ANDROID)
  23.  
  24.             try {
  25.                 isLoggedIn.Value = false;
  26.                 if(PlayGamesPlatform.Instance.IsAuthenticated()) {
  27.                     isLoggedIn.Value = true;
  28.                     username.Value = PlayGamesPlatform.Instance.GetUserDisplayName();
  29.                     userID.Value = PlayGamesPlatform.Instance.GetUserId();
  30.                 }
  31.             }
  32.             catch(Exception e) {
  33.                 Debug.LogError(e.ToString ());
  34.             }
  35. #endif
  36.             Finish();
  37.         }
  38.     }
  39. }
RAW Paste Data