83 lines
2.6 KiB
C#
83 lines
2.6 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using GooglePlayGames;
|
|
using GooglePlayGames.BasicApi;
|
|
using UnityEngine.SocialPlatforms;
|
|
using System.Threading;
|
|
using UnityEngine.UI;
|
|
using Firebase.Firestore;
|
|
using Firebase.Extensions;
|
|
using System;
|
|
using UnityEngine.Networking;
|
|
using System.Text.RegularExpressions;
|
|
using TMPro;
|
|
|
|
|
|
public class gplayAuth : MonoBehaviour{
|
|
|
|
public TMP_Text gplayText;
|
|
public TMP_Text firebaseStatText;
|
|
public string AuthCode;
|
|
|
|
void Start() {
|
|
|
|
PlayGamesPlatform.Activate();
|
|
//GPGSLogin();
|
|
}
|
|
|
|
public void GPGSLogin(){
|
|
PlayGamesPlatform.Instance.Authenticate((success) => {
|
|
if(success == true){
|
|
//logged into Google Play Games
|
|
gplayText.text = "G-Play Connected";
|
|
Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWithOnMainThread(task => {
|
|
|
|
if(task.Result == Firebase.DependencyStatus.Available){
|
|
//no dependency issue with firebase, continue to login
|
|
ConnectToFirebase();
|
|
}
|
|
else{
|
|
//error with firebase Dependecies plugin
|
|
firebaseStatText.text = "Dependency Error";
|
|
}
|
|
|
|
}
|
|
);
|
|
|
|
}
|
|
else{
|
|
Debug.LogError("Gplay failed");
|
|
}
|
|
}
|
|
|
|
);
|
|
}
|
|
|
|
void ConnectToFirebase(){
|
|
// PlayGamesPlatform.Instance.RequestServerSideAccess(true , code => {
|
|
// AuthCode = code;
|
|
// Firebase.Auth.FirebaseAuth FBAuth = Firebase.Auth.FirebaseAuth.DefaultInstance;
|
|
// Firebase.Auth.Credential FBCred = Firebase.Auth.PlayGamesAuthProvider.GetCredential(AuthCode);
|
|
// FBAuth.SignInWithCredentialAsync(FBCred).ContinueWithOnMainThread(task => {
|
|
// if(task.IsCanceled){
|
|
// firebaseStatText.text = "sign in cancelled";
|
|
|
|
// }
|
|
// if(task.IsFaulted){
|
|
// firebaseStatText.text = "Error:"+task.Result;
|
|
// }
|
|
|
|
// Firebase.Auth.FirebaseUser user = FBAuth.CurrentUser;
|
|
// if(user != null){
|
|
// firebaseStatText.text = "Signed in As :"+ user.DisplayName;
|
|
// }
|
|
// else{
|
|
// //error getting username
|
|
// }
|
|
// });
|
|
// });
|
|
}
|
|
|
|
}
|