Unity
Add the Depot SDK to a Unity project and check the base game and DLC from the player's offline license.
The Unity package com.depot.games.sdk checks whether the player owns your game and its DLC. It reads the signed license the Depot launcher stores, with no network requests and no sign-in inside the game.
Requirements
- Unity 6 (6000.0 LTS or later).
- A Depot game and its id (
game_…). Rundepot game show my-gameto see it. - The package currently ships its native library for macOS only. Windows and Linux builds aren't available yet.
Install the package
The package isn't on a package registry yet. It's a folder, com.depot.games.sdk, that you add from disk.
- Copy the
com.depot.games.sdkfolder somewhere stable, next to your project. - In Unity, open Window → Package Manager.
- Press +, choose Install package from disk, and pick the folder's
package.json.
Configure it
Create a settings asset with Assets → Create → Depot → SDK Settings. It holds nothing secret.
| Field | What to set |
|---|---|
| Game Id | Your game's id, game_…. |
| Environment | Staging. Production isn't launched yet, and the SDK refuses Production until it is. The default is Production, so change it. |
| Policy | Offline Lease (default), Online Required or Optional. See below. |
| Freshness Hours | Online Required only: how old a license may be, in hours (default 24). |
| Critical Files | Paths inside the installation that a Critical integrity check hashes, for example MyGame.app/Contents/MacOS/MyGame. |
| Integrity Excluded | Path prefixes a Full integrity check skips, such as folders the game rewrites. |
Policies
- Offline Lease: a valid license decides. An expired license gives
Expired, and no license givesUnknown. - Online Required: like Offline Lease, but the license must be newer than the freshness window, otherwise
RefreshNeeded. - Optional: results are advisory (
Advisoryistrue). Use this to show information without enforcing anything.
Check the base game and DLC
Create the SDK once, keep it for the life of the game, and dispose of it when you're done. HasEntitlement takes a package name, such as base or the name you gave a DLC package. It does no I/O, so you can call it whenever you need it.
using Depot.Games.Sdk;
using UnityEngine;
public sealed class Ownership : MonoBehaviour
{
public DepotSdkSettings settings;
DepotSdk sdk;
void Start()
{
try
{
sdk = DepotSdk.Initialize(settings);
}
catch (DepotSdkException e)
{
Debug.LogWarning($"Depot SDK didn't start: {e.Kind}: {e.Message}");
return;
}
var baseGame = sdk.HasEntitlement("base");
var expansion = sdk.HasEntitlement("expansion-1");
if (expansion.Status == EntitlementStatus.Granted) UnlockExpansion();
if (baseGame.Status == EntitlementStatus.Unknown) ShowNoLicenseMessage();
}
void OnDestroy() => sdk?.Dispose();
void UnlockExpansion() { /* your code */ }
void ShowNoLicenseMessage() { /* your code */ }
}HasEntitlement returns an EntitlementResult with:
Status:Granted,Denied,Unknown,Expired,RefreshNeededorError.Kind: the package kind, such asbaseordlc.ValidUntil: when this entitlement ends, in Unix seconds, or 0 for no end.LicenseExpiresAt: when the stored license expires, in Unix seconds.Advisory:trueunder the Optional policy.ClockAnomaly:trueif the computer's clock looks earlier than it should be. It's a warning only.
Unknown means there's no license on this computer, not that the player doesn't own the game. Tell the player to open the Depot launcher rather than treating them as a non-owner.
Owning a DLC never implies owning the base game. Check each package you care about.
React when the license changes
If a player redeems a DLC key in the launcher while your game is running, the launcher refreshes the stored license. Your game picks it up when it calls ReloadAsync. The SDK never polls on its own, so call it when it makes sense, for example when the player opens the DLC menu or presses a "Reload" button.
sdk.EntitlementsChanged += snapshot => Debug.Log($"License changed: {snapshot.State}");
async void OnReloadPressed()
{
var snapshot = await sdk.ReloadAsync();
if (sdk.HasEntitlement("expansion-1").Status == EntitlementStatus.Granted) UnlockExpansion();
}ReloadAsync completes on Unity's main thread and raises EntitlementsChanged only when something changed. GetSnapshot() returns the current state without I/O: State (Valid, Expired, Missing, Invalid or RefreshNeeded), ExpiresAt, the Entitlements list and, for an invalid license, ErrorKind.
Verify the installed files
You can check the installed files against the release you signed. It's never automatic. It runs off the main thread and reports progress from 0 to 1.
var report = await sdk.VerifyInstallationAsync(IntegrityMode.Full, new System.Progress<float>(p => progress = p));
if (!report.Ok) Debug.Log($"{report.Modified.Count} modified, {report.Missing.Count} missing");| Mode | What it checks |
|---|---|
Manifest | The release signature and metadata only. |
Critical | The files listed in Critical Files. |
Full | Every file Depot installed, except Integrity Excluded prefixes. |
Files that aren't part of the release, such as saves and mods, never count as failures.
Test it
You need a license on your own computer for your game. The simplest way is to own the game on staging and let the CLI store your license.
Own the game
Claim it on your store page, or grant it to yourself:
depot entitlement grant --game my-game --handle @your-handleStore your license
Sign in as yourself and fetch the license. Installing with the launcher or depot install also stores it.
depot login
depot license refresh --game my-game
depot license show --game my-gamedepot license show prints the cached license's state, expiry and entitlements, without the network.
Run the game
Press Play in the Editor. HasEntitlement("base") should return Granted.
Test DLC
Create a DLC package, then grant it to yourself (or issue a key and redeem it with depot redeem):
depot package create --game my-game --name expansion-1 --kind dlc --title "Expansion 1"
depot entitlement grant --game my-game --package expansion-1 --handle @your-handle
depot license refresh --game my-gameCall ReloadAsync in the running game. HasEntitlement("expansion-1") changes from Denied to Granted.
To test with no license, run depot logout. Signing out removes the licenses the CLI wrote, and the SDK then reports Unknown.
Development overrides
Development builds and the Editor can pass DevelopmentOverrides to DepotSdk.Initialize, for example licenseDirectory to read licenses from a test folder, or installRoot for integrity checks. Release builds refuse overrides.
sdk = DepotSdk.Initialize(settings, new DevelopmentOverrides { licenseDirectory = "/tmp/depot-test-licenses" });