Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.5 kB
22
Indexable
Never
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GooglePlayGames;
using GooglePlayGames.BasicApi;
using UnityEngine.UI;


public class GPGS : MonoBehaviour
{
    public Text statusTxt;
    // Start is called before the first frame update
    void Start()
    {

        PlayGamesPlatform.Activate();
        PlayGamesPlatform.Instance.Authenticate(ProcessAuthentication); //automatically creates the build configuration, activates it and authenticates the user.
    }
    internal void ProcessAuthentication(SignInStatus status) // called on start, this handles the call back method received from play games platform and processes the result.
    {
        if (status == SignInStatus.Success)
        {
            statusTxt.text = "Successful Sign In" + Social.localUser.userName ;
        }
        else if (status == SignInStatus.InternalError)
        {
            statusTxt.text = "Failed due to internal error";
        }
        else if (status == SignInStatus.Canceled)
        {
            statusTxt.text = "Failed due to Canceled status";
        }
        else
        {
            statusTxt.text = "This should never be triggered, not one of the call back responses.";
        }
    }
    public void TriggerManualSignIn() // the script attached to the button to trigger a manual signin.
    {
        PlayGamesPlatform.Instance.ManuallyAuthenticate(ProcessAuthentication);
    }
}