Getting Started
Unity SDK — Getting Started
Skill — Download
This guide shows the minimum setup to run OAuth login and wallet actions with the CROSSx Unity SDK.
Requirements
- Unity 2022.3 LTS+
- Newtonsoft.Json (
com.unity.nuget.newtonsoft-json) - UI Toolkit (built-in)
1) Install (UPM)
Option A — Scoped Registry
Add the registry and package to Packages/manifest.json:
{
"scopedRegistries": [
{
"name": "NexusCROSSxUPM",
"url": "https://package.cross-nexus.com/repository/dev-crossx-sdk-unity",
"scopes": ["com.crossx"]
}
],
"dependencies": {
"com.crossx.sdk.unity": "<version>"
}
}Option B — Git URL
Window → Package Manager → Add package from git URL:
https://github.com/to-nexus/crossy-sdk-unity.git?path=src/CROSSx.Sdk.Unity#<version>
Or add directly to Packages/manifest.json:
{
"dependencies": {
"com.crossx.sdk.unity": "https://github.com/to-nexus/crossy-sdk-unity.git?path=src/CROSSx.Sdk.Unity#<version>"
}
}Option C — Local (development)
{
"dependencies": {
"com.crossx.sdk.unity": "file:../../crossy-sdk-unity/src/CROSSx.Sdk.Unity"
}
}2) Configure deep link callback
OAuth completes in a native browser and redirects back using a custom URI scheme: crossx-{ProjectId}.
Android
Add an intent filter in Assets/Plugins/Android/AndroidManifest.xml:
<activity
android:name="com.unity3d.player.UnityPlayerActivity"
android:exported="true"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="crossx-YOUR_PROJECT_ID" />
</intent-filter>
</activity>iOS
Register the URL scheme in Xcode (handled automatically by the SDK's iOSBuildPostProcessor), or add it manually in Project Settings → Supported URL schemes.
Windows
A register_deeplink.reg file is generated automatically after build. Run it to register the URI scheme in the Windows registry.
3) Create SDK instance
using CROSSx.Sdk.Unity.SDK;
using CROSSx.Sdk.Unity.Core.Types;
var config = new SDKConfig
{
ProjectId = "YOUR_PROJECT_ID",
OAuthServerUrl = "https://dev-cross-wallet-oauth.crosstoken.io",
AuthApiUrl = "https://dev-cross-auth.crosstoken.io",
EmbeddedWalletGatewayUrl = "https://dev-embedded-wallet-gateway.crosstoken.io/api/v1",
Theme = ThemeMode.Dark,
AppName = "My Game",
Debug = true
};
var sdk = CROSSxSDKFactory.Create(config);4) Initialize and enable confirmation UI
using UnityEngine;
using UnityEngine.UIElements;
public class GameManager : MonoBehaviour
{
[SerializeField] private UIDocument uiDocument;
private CROSSxSDK sdk;
async void Start()
{
var config = new SDKConfig { /* ... */ };
sdk = CROSSxSDKFactory.Create(config);
var authResult = await sdk.InitializeAsync();
if (authResult != null)
Debug.Log($"Session restored: {authResult.WalletAddress}");
sdk.EnableSignConfirmation(uiDocument.rootVisualElement);
}
}5) Basic auth flow
var authResult = await sdk.InitializeAsync();
bool ok = await sdk.EnsureLoggedInAsync();
var auth = await sdk.SignInAsync(SDKLoginProvider.Google);
await sdk.SignOutAsync();6) Basic wallet flow
string chainId = "eip155:612044";
var addr = await sdk.GetAddressAsync();
var balance = await sdk.GetBalanceAsync(
address: addr.Address,
chainId: chainId
);Updated about 18 hours ago