Skip to main content
The Unity package works the same on every platform, with the sign-in that fits each one: Unity 2021.3 or later. The source and releases are at github.com/Gamavas/pass-unity (MIT).

Install

1

Add the package

In Unity, open Window → Package Manager → + → Add package from git URL… and enter:
Or add it to Packages/manifest.json:
Packages/manifest.json
2

Connect your game

At developer.gamavas.fun, connect your game listing to get a client ID. It’s public, so it’s fine in your build.Under Where sign-in returns, add an address for each platform you ship:
3

Start the SDK

Call Init once, as early as you can:
Login.cs

Sign players in

The quickest way is the GamavasSignInButton component: add it to any UI element and listen to its On Signed In event. It needs an EventSystem in the scene, like any UI button. The component starts the sign-in on press, not on release. That matters on WebGL: browsers only open popups during a click, so the popup opens on that same click. To use your own button, call SignInAsync from its click handler:
player.id is the player’s Gamavas ID: the same in every game, so it’s the one to store. Pass askForEmail: true to also ask for their email. They can decline, and then player.email is null.
Players stay signed in between sessions. On startup, check GamavasPass.Player. On WebGL and mobile, await GamavasPass.Ready first: it finishes a sign-in that came back while the game was loading.
To sign the player out of your game (not of Gamavas), call await GamavasPass.SignOutAsync().

Achievements and XP

Add achievements to your app in the developer portal, then unlock them from your game:
Unlocking again is harmless: newlyUnlocked is false and no XP is added. On WebGL, Gamavas shows an “Achievement unlocked” notice; pass notify: false to show your own. On desktop and mobile, show your own.
Achievements marked server in the portal can’t be unlocked from the game, so a modified client can’t grant them. Unlock them from your server.

Sell your game

Set a price on your app’s Store page in the developer portal, then gate your game on ownership:
Players pay by card or with purchased Gamavas coins, and you get 90% of the price. On WebGL the checkout is a popup, so call PurchaseAsync from a click. On desktop and mobile it opens the browser and checks every few seconds until the game is owned, for up to 15 minutes.
Mobile app stores have their own rules for selling digital content inside apps, and buying through Gamavas’s checkout can break them. Check the App Store and Google Play rules before calling PurchaseAsync in a store build. OwnsAsync is fine everywhere, so a game bought on the web still unlocks.
To try this without paying, turn on test mode: new GamavasPassOptions { Test = true }. The checkout then offers a free Complete test purchase button, for you and the testers you add on the Store page. Turn it off before you ship.

Platforms

Add the Gamavas script to your WebGL template’s <head> (or the built index.html):
The SDK loads the script itself if it’s missing. In the <head>, though, the sign-in popup can close before Unity starts loading in it.

Mobile

1

Register the link

In the developer portal, under Where sign-in returns, add your bundle ID in lower case, then :/pass. You’ll find the bundle ID in Player Settings → Other Settings → Package Name / Bundle Identifier.A bundle ID with an underscore can’t be a link. In that case, choose your own: a reverse domain name you own, with one slash.
2

iOS: add the URL scheme

In Player Settings → Other Settings → Supported URL schemes, add the part before the colon, for example com.studio.game.
3

Android: add an intent filter

Turn on Custom Main Manifest in Player Settings → Publishing Settings. Then, in Assets/Plugins/Android/AndroidManifest.xml, add this inside the <activity> that has the LAUNCHER intent filter:
AndroidManifest.xml
SignInAsync fails with code cancelled about 2 seconds after the game is back in front, so your button doesn’t stay stuck. If they then finish in the browser after all, the link still signs them in and PlayerChanged fires.
The sign-in is saved before the browser opens. When the link starts the game again, the SDK finishes it. await GamavasPass.Ready after Init if your first scene needs to know who’s signed in.

Your server

If your game has a server, never trust a player ID the game sends. Send the player’s access token instead, and let your server ask Gamavas who it belongs to:
On your server, @gamavas/pass-server checks it with your secret key:
server.ts

Options

Errors

Every failure throws a GamavasPassException with a Code and Gamavas’s explanation in Message: