A set of tools for Unity to allow handling Google Sign-in for Android and iOS.
GoogleSigninPlugin.unitypackage
- Menu/Settings/Google
- Setting ClientId and ClientSecret to GoogleSettings.asset
- Setting ClientId and UrlScheme to GoogleSettings.asset
- Setting ClientId and ClientSecret to GoogleSettings.asset
using GoogleSignIn;
Call the "SignIn" method and check the items you want to get.
public IEnumerator Example()
{
yield return GoogleSigninPlugin.Instance.SignIn(
requestEmail:true,
requestId:true,
requestIdToken:true,
requestServerAuthCode:true,
requestProfile:true);
Debug.Log(GoogleSigninPlugin.Instance.Email);
Debug.Log(GoogleSigninPlugin.Instance.Id);
Debug.Log(GoogleSigninPlugin.Instance.IdToken);
Debug.Log(GoogleSigninPlugin.Instance.ServerAuthCode);
Debug.Log(GoogleSigninPlugin.Instance.DisplayName);
}
public void Example()
{
GoogleSigninPlugin.Instance.SignOut();
}
Replace main Activity.
<!--
<activity android:name="com.unity3d.player.UnityPlayerActivity" ...
-->
<activity android:name="com.hiyorin.googlesignin.CustomUnityPlayerActivity" ...
Please pass the value of OnActivityResult of your Activity
public void Exapmle(int requestCode, int resultCode, AndroidJavaObject data)
{
GoogleSigninPlugin.Instance.AndroidActivityResult(requestCode, resultCode, data);
}