SDK / Unity

Install the SDK

UnstableUnity 6000.6+

You don't copy the SDK into your repository. Your project commits a small loader, and the loader asks the ase command line to install the SDK when you open the project in the editor. Everyone on the team gets the same SDK, and nobody commits its files.

Before you start

  1. Install ase.
  2. Sign in with ase login.
  3. Have a game on Brain. A game you make with ase new-game comes with the loader and SDK already set up, so you can skip to the loader.

Add the SDK to an existing project

From the root of your engine project:

ase sdk install --game <game-id>

This downloads the SDK, installs it into the engine's SDK folder and wires it into the project. It is safe to run again: a second run changes nothing.

Engine Installs into Also sets up
Unity Packages/com.asebrain.sdk The package in the project

What you commit

Commit the loader and the project config. Keep the SDK itself ignored; ase sdk install writes the ignore rules for you.

Engine Commit Keep ignored
Unity brain/project.toml, .gitignore, Packages/com.asebrain.sdk.loader Packages/com.asebrain.sdk, .ase

ase sync keeps the loader files up to date. Don't edit them: the next sync replaces local changes.

Choose an SDK version

brain/project.toml holds your project's SDK policy. New projects track the newest release:

package_version = "latest"

To pin a release, install it by version. The pin is written to brain/project.toml, so the whole team gets the same one:

ase sdk install --version 1.4.0

To go back to tracking the newest release:

ase sdk update

What happens when you open the project

Each time the editor opens your project, the loader runs ase sdk ensure in the background and shows you its answer:

  • No SDK on this machine yet. It installs at once. Restart the editor to load it.
  • A newer release is out. A dialog offers it. Restart now and it installs, then reopens the project; choose later and it installs when you close the editor.
  • Up to date. Nothing to show.

The loader never replaces an SDK the editor has loaded. Updates always wait for the editor to exit, and if one fails, the loader tells you the next time you open the project.

Offline and signed out

Once the SDK is installed, you can work offline and signed out. ase sdk ensure answers from what this machine already has: the installed SDK and the download cache. The loader logs a warning that it couldn't check for updates, and the SDK keeps working.

When the game can't run

Only two things stop the game from running:

  • No SDK is installed on this machine, for example on a fresh clone while you're offline.
  • The project pins a version that is neither installed nor in the download cache.

Then the editor shows a dialog and refuses to play the game until you fix it. The message says what to do: run ase login when you're signed out, or try again when ASE Brain can't be reached.

Edited SDK files

The SDK folder belongs to Brain. If you edit a file in it, Brain stops updating the SDK so it never overwrites your change, and the loader names the file. To get back to a clean SDK, delete the SDK folder and reopen the editor.

When the loader stays quiet

The loader skips:

  • Headless and batch editors, and CI.
  • Editors that ase editor starts, because ase editor prepares the SDK before it opens the project.
  • Any editor started with ASE_SDK_LOADER=0 in its environment.

The loader finds ase through the ASE_CLI environment variable, then PATH, then the default install folders. If it can't find ase, it tells you to install it.

Engine notes

The loader is the embedded package Packages/com.asebrain.sdk.loader. Unity compiles your scripts before the loader can install anything, so keep every script that uses Brain in an assembly that compiles only when the SDK is present:

{
  "name": "Game",
  "references": ["Ase.Brain"],
  "autoReferenced": true,
  "defineConstraints": ["ASE_BRAIN_SDK"],
  "versionDefines": [
    { "name": "com.asebrain.sdk", "expression": "0.0.0", "define": "ASE_BRAIN_SDK" }
  ]
}

A project without the SDK then still compiles, the loader runs instead of Safe Mode, and Play mode stays blocked until the SDK is in.

ase sdk ensure

Loaders call this command, and you can too, for example to check a project in a script:

ase sdk ensure --project .

It prints one line of JSON:

{"protocol":1,"status":"update_ready","installed":"1.4.0","available":"1.5.0","freshness":"verified","blocking":false,"code":null,"message":"Brain SDK 1.5.0 is ready. Restart the editor to install it.","apply_error":null}
Field Meaning
status current, installed (it just installed one), update_ready (one waits for the editor to close) or error
installed The SDK version on disk after this call
available The version that installs once the editor exits
freshness verified (checked against Brain's signed release list), unverified (from this machine's cache) or skipped
blocking true when the game can't run until this is fixed
code Why, when something went wrong: signed_out, offline, modified, untrusted, failed or cli_too_old
message What to tell a person
apply_error Why the last install after an editor exit failed
Flag Does
--project <path> The project; the current folder by default
--editor An editor has the project open, so a loaded SDK is never replaced: a newer one reports update_ready
--no-check Skips the check for a newer release while a verified SDK is installed
--offline Uses only what this machine has

ase sdk apply --wait-pid <pid> installs the waiting SDK once that editor process exits. Loaders start it for you.

Other SDK commands

Command Does
ase sdk status Shows the installed SDK and checks its files, without the network
ase sdk download --engine <engine> Fills the download cache without installing, for working offline later
ase sdk migrate Converts a project that committed its SDK to the loader, keeping your local files

See the ase sdk reference for every flag.