Getting Started

Unity SDK — Getting Started

SkillDownload

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)

The Webkit SDK (com.crossx.webkit.sdk.unity) is bundled as a dependency of com.crossx.sdk.unity and installed automatically. No separate installation is required.

1) Install (UPM)

Option A — Scoped Registry

Add the registry and package to Packages/manifest.json:

{
  "scopedRegistries": [
    {
      "name": "NexusCROSSxUPM",
      "url": "https://registry.npmjs.org",
      "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) Configure the environment

The SDK selects API endpoints automatically based on the Environment field in the CROSSx SDK Settings asset (Assets/Resources/CROSSx SDK Settings.asset). Set it to Prod for production builds.

In the Unity Editor: open Edit → Project Settings → CROSSx SDK (or select the Settings asset directly) and set the environment and Project ID there.

URL override fields (OAuthServerUrl, AuthApiUrl, EmbeddedWalletGatewayUrl) in SDKConfig are optional. Leave them empty to use the endpoints resolved from the active environment.

4) Create SDK instance

using CROSSx.Sdk.Unity.SDK;
using CROSSx.Sdk.Unity.Core.Types;

var config = new SDKConfig
{
    ProjectId = CROSSxSdkSettings.GetProjectId(), // reads from Settings asset
    Theme = ThemeMode.Dark,
    AppName = "My Game",
    Debug = true
};

var sdk = CROSSxSDKFactory.Create(config);

5) 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);
    }
}

6) Basic auth flow

var authResult = await sdk.InitializeAsync();

bool ok = await sdk.EnsureLoggedInAsync();

var auth = await sdk.SignInAsync(SDKLoginProvider.Google);

await sdk.SignOutAsync();

7) Basic wallet flow

string chainId = "eip155:612044";

var addr = await sdk.GetAddressAsync();
var balance = await sdk.GetBalanceAsync(
    address: addr.address,
    chainId: chainId
);