Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using GooglePlayGames;
- using UnityEngine;
- using UnityEngine.SocialPlatforms;
- using System;
- namespace HutongGames.PlayMaker.Actions
- {
- [ActionCategory("Google Play")]
- [Tooltip("Is the user logged in. If they are it will fill in username and userID")]
- public class IsLoggedIn : FsmStateAction
- {
- [RequiredField]
- [UIHint(UIHint.Variable)]
- public FsmBool isLoggedIn;
- [UIHint(UIHint.Variable)]
- public FsmString username;
- [UIHint(UIHint.Variable)]
- public FsmString userID;
- public override void OnEnter()
- {
- #if !UNITY_EDITOR && (UNITY_IOS || UNITY_ANDROID)
- try {
- isLoggedIn.Value = false;
- if(PlayGamesPlatform.Instance.IsAuthenticated()) {
- isLoggedIn.Value = true;
- username.Value = PlayGamesPlatform.Instance.GetUserDisplayName();
- userID.Value = PlayGamesPlatform.Instance.GetUserId();
- }
- }
- catch(Exception e) {
- Debug.LogError(e.ToString ());
- }
- #endif
- Finish();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement