This plugin provides seamless Google authentication support for Unity applications targeting mobile platforms. It handles all native SDK setup and provides a simple C# API to sign in users, retrieve their profile info, and manage tokens.
This plugin requires Google External Dependency Manager for Unity (EDM4U) to be present in the project to automatically resolve and manage native dependencies for Android and iOS.
By pckgs.io
Add the following scoped registry to your project's Packages/manifest.json file:
"scopedRegistries" : [
{
"name": "pckgs.io",
"url": "https://upm.pckgs.io",
"scopes": [
"com.vuzmir"
]
}
],Then add the package dependency under the "dependencies" section:
"dependencies" : {
"com.vuzmir.google-sign-in": "1.0.0"
}You can install this plugin via Git URL using Unity Package Manager.
https://github.com/yvz-dmr/unity-google-sign-in.git
-
In Unity, create a GoogleSignInOptions asset:
- Right-click inside the
Assets/Resourcesfolder (create the folder if it doesn't exist) - Select
Create → Vuzmir → Google Sign In Options
- Right-click inside the
-
Select the newly created asset and fill in the required fields:
AndroidClientIdorIOSClientIdor both depending on your target platform
Make sure this asset is placed at the root of the
Resourcesfolder, so it can be loaded correctly.
Once you’ve completed the configuration steps, you can start using the plugin to authenticate users via GoogleSignInManager.
Here’s a basic example of how to use it in a MonoBehaviour:
using System.Threading.Tasks;
using UnityEngine;
using Vuzmir.UnityGoogleSignIn;
public class LoginManager : MonoBehaviour
{
public async void SignInWithGoogle()
{
try
{
var result = await new GoogleSignInManager().SignIn();
// Handle result
Debug.Log(result.IdToken);
}
catch (GoogleSignInException ex)
{
// Handle error
Debug.LogError($"Google Sign-In failed: {ex.Message}");
}
}
}