# Rudder Unity SDK

This project hosts the `rudder.sdk` UPM package and the scenes that show how
to call it. Agents integrating the SDK into a game should read
`Packages/rudder.sdk/AGENTS.md`.

## Requirements

- Unity `6000.5.6f1`.
- A Rudder project key.
- Network access to `https://api.rudder.build`.

## Quick Start

1. Open this folder in Unity `6000.5.6f1`.
2. Copy `Assets/LiveOpsLocal.asset.example` to `Assets/LiveOpsLocal.asset`
   (the real asset is git-ignored because it holds your project key).
3. Set `ProjectKey` to your project key.
4. Confirm `BaseUrl` is `https://api.rudder.build`.
5. Open a feature sample under `Assets/Samples/Rudder SDK/` and press Play.
   In this development project the samples are already linked there; do not
   import them again from Package Manager.

## Feature Samples

Each scene is one Rudder API. The scripts live in
`Packages/rudder.sdk/Samples~` and are the copy-paste examples for the SDK.

| Scene | SDK calls |
| --- | --- |
| `Authentication/Authentication.unity` | `Rudder.Initialize`, `Auth.LoginWithDeviceAsync`, `Player.GetProfileAsync`, `Auth.Logout` |
| `RemoteConfig/RemoteConfig.unity` | `RemoteConfig.LoadAsync`, `Get(key, fallback)` |
| `Storage/Storage.unity` | `Storage.GetAsync`, `SaveAsync`, `DeleteAsync` |
| `StoreInventory/StoreInventory.unity` | `Stores.ListAsync`, `PurchaseAsync`, `Inventory.GetAsync` |
| `Leaderboards/Leaderboards.unity` | `Leaderboards.FindBySlug`, `SubmitAsync`, `ListAsync` |
| `Scenarios/Scenarios.unity` | `Scenario.TriggerAsync`, `Effects.OnNotification`, `Effects.OnStoreOffer`, … |

The later scenes are more interesting with this staging data:

| Feature | Expected setup |
| --- | --- |
| Remote Config | Optional keys: `demo_round_seconds`, `demo_player_speed`. Defaults are used when keys are missing. |
| Stores | A store with slug `cozy-camp-shop` with at least one offer. |
| Leaderboards | A leaderboard with slug `cozy-collector-score`. |
| Scenarios | Events `player_login` and/or `demo_round_finished`. |
| Storage | No setup required; the sample writes type `sample_save`, id `main`. |

## Project Structure

```text
Assets/Samples/Rudder SDK/       (symlink to the package Samples~)
Packages/rudder.sdk/
  Runtime/                       (Rudder.Unity + Rudder.Core.dll)
  Samples~/                      (feature sample scenes)
Assets/LiveOpsLocal.asset        (git-ignored; copy from LiveOpsLocal.asset.example)
```

## Updating Core DLLs

Build the C# SDK from the sibling repository and copy the assembly into the
UPM package:

```sh
dotnet build ../liveops-csharp-sdk -c Release
cp ../liveops-csharp-sdk/bin/Release/netstandard2.1/Rudder.Core.dll \
  Packages/rudder.sdk/Runtime/Plugins/Rudder.Core.dll
```

`Rudder.Core` depends only on Newtonsoft.Json, which Unity provides through
the `com.unity.nuget.newtonsoft-json` package — no other DLLs are bundled.
