Skip to content

Unity

Unity projects targeting Android and iOS.

Run alphyn-cli integrate from the root of a Unity project (the folder containing ProjectSettings/). It:

  1. Downloads the Unity plugin and the iOS framework, verifying each one’s integrity before any write. The Android library (the com.byterialab:alphyn-sdk AAR) is not downloaded: it resolves from the Alphyn package registry at build time.
  2. Places the C# plugin under Assets/AlphynSDK/ and the iOS framework under Plugins/iOS/, and wires the Android SDK to resolve from the registry through the project’s custom Main Gradle Template (Assets/Plugins/Android/mainTemplate.gradle): it adds the registry Maven repository and the com.byterialab:alphyn-sdk dependency. No AAR is copied into your project.
  3. Writes a post-build script (Assets/AlphynSDK/Editor/AlphynRegisterPostBuild.cs) that registers the build after a successful player build. It hard-codes no host or API key (both are resolved when the CLI runs), so there is no staging/production split baked into your project.
  4. Records the result in alphyn.json.

Two settings make the registry wiring take effect. In Player Settings > Publishing Settings, enable Custom Main Gradle Template so Unity uses mainTemplate.gradle, and supply your app API key as ALPHYN_REGISTRY_KEY in the build environment. iOS needs no registry key: its framework is bundled. See SDK Registry Access and Installation:

Terminal window
export ALPHYN_REGISTRY_KEY=<YOUR_APP_API_KEY>

If your build cannot reach the registry, use the self-contained plugin that carries the AAR instead: see Offline: the self-contained plugin.

Unity projects are created in the Unity Editor, so alphyn-cli new unity is not supported. Create the project in the Editor, then run integrate in the project folder.

A Unity Android player build is an ordinary APK, so it registers like a native Android build; the post-build script invokes alphyn-cli register --apk <built-apk> for you. A Unity iOS build registers from its generated Xcode project’s post-build step. There is normally nothing to run by hand.

A Unity project that ships both platforms enrolls under one portal app per platform, each with its own API key (see How to Register Your App). integrate --android-api-key <key> provisions the Android app’s key into a gitignored .alphyn/android-api.key file that the post-build hook reads automatically, so an Android player build registers with no further setup; override it per build with the ALPHYN_ANDROID_API_KEY_FILE environment variable (a key-file path), or pass --android-api-key / --android-api-key-file for a manual register. A Unity iOS build produces an Xcode project, so its iOS app’s key is supplied through the Xcode post-action flow. The backend accepts a registration only from the matching platform’s key.

Confirms the Unity project is valid, the plugin is placed, the iOS framework is present, and the Android SDK is wired (either the registry Maven repository and coordinate in mainTemplate.gradle, or a bundled .aar on an offline install). It also checks that the Android Minimum API Level meets the SDK’s floor, that the post-build script is present, and that the placed plugin tree still matches the recorded checksum.

Deletes the CLI-owned Assets/AlphynSDK subtree (the plugin, any bundled native binaries, and the post-build script), unwires the registry from the custom Main Gradle Template, and removes alphyn.json.

Unity Android runtime initialization is being finalized together with the SDK. After integrating, alphyn-cli doctor surfaces the current status, so you always know whether a build is ready.