> ## Documentation Index
> Fetch the complete documentation index at: https://docs.qwacks.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Unity package

> Turn your Unity game into a playtest build for Protokite, step by step.

Protokite Playtest is an optional Unity package that turns a build of your game into a **playtest build**.
While a playtest runs, every launch of the game becomes one session on the playtest's **Sessions** page,
and the playtest decides what that session collects. It needs no code: install it, point it at your
playtest, sign a player in, and press **Play**.

<Card title="Get the package" icon="download" href="https://github.com/QwackStack/FlockUnitySdk/releases">
  The Flock SDK's **Playtesting** tab installs it in one click. `ProtokitePlaytest-<version>.unitypackage` is
  also attached to every Flock Unity SDK release, at the same version.
</Card>

## What a playtest collects

| Playtest feature | What the build sends | Where it shows |
| - | - | - |
| Always | One session per launch, named after the player's Steam ID or this install's device ID | Protokite **Sessions** |
| Video recording | A recording of the game's screen, uploaded when it ends | The session's recording player |
| Heavy analytics | A performance window every ten seconds of play, each scene load, and your own playtest events | Flock **Dashboards → Game Metrics**, under the `playtest` category |
| Exception capturing | Nothing extra — the Flock SDK reports exceptions with its own setting, whatever the playtest turns on | Flock **Diagnostics → Errors** |
| A published feedback form | The player's answers | The session card, and the playtest's **Feedback form** page |

Every one of them is switched on the playtest's page in Protokite, so changing what a playtest
collects needs no new build — and the player is asked first, so a launch collects only what they
allowed. See [Press Play](#step-5-press-play). Each feature is described on
[What a playtest collects](/protokite/unity-features).

## Before you start

* **The Flock SDK is set up and working** in the project: **Api Url**, **Api Key**, **Game Name** and
  **Game Version** in **Flock → Settings**, with a **Resolved Version ID** filled in. See the
  [Unity SDK](/sdk/unity) page.
* **A playtest exists in Protokite.** Creating one makes a Flock game version for it, named `pt-`
  followed by the test's ID.
* **Video is recorded on 64-bit Windows only.** Every other platform runs the rest of the playtest and
  says once in the log that it records no video. See [Platforms](/protokite/unity-features#platforms).

## Step 1: Install the package

<Steps>
  <Step title="Open the Playtesting tab">
    In the Unity menu bar, choose **Flock → Settings** and select the **Playtesting** tab. It names the
    version it will install, which always matches your Flock SDK.

    <Frame caption="Flock → Settings → Playtesting, before the package is installed.">
      <img src="https://mintcdn.com/qwacks/ByDUWjWU5EEoXzc3/images/protokite/unity/playtesting-tab-install.png?fit=max&auto=format&n=ByDUWjWU5EEoXzc3&q=85&s=23f47b1f1d8cf3e237148c027a277a4c" alt="The Flock settings window on its Playtesting tab, showing Not installed and an Install Protokite Playtest button" width="560" height="275" data-path="images/protokite/unity/playtesting-tab-install.png" />
    </Frame>
  </Step>

  <Step title="Press Install Protokite Playtest">
    It downloads the package from the Flock SDK's release and imports it into `Assets/ProtokitePlaytest`.
    No Git is needed. Unity compiles it, and the tab then shows the installed version with two buttons you
    use in the next steps: **Open Playtest Settings** and **Check Playtest Setup**.

    <Frame caption="The same tab once the package is installed: its version, where it is, and the buttons for the next steps.">
      <img src="https://mintcdn.com/qwacks/ByDUWjWU5EEoXzc3/images/protokite/unity/playtesting-tab-installed.png?fit=max&auto=format&n=ByDUWjWU5EEoXzc3&q=85&s=62ae523d3652fe1f9a632e653504e1b8" alt="The Playtesting tab showing the installed version with Open Playtest Settings, Check Playtest Setup and Remove buttons" width="560" height="308" data-path="images/protokite/unity/playtesting-tab-installed.png" />
    </Frame>
  </Step>
</Steps>

<Tip>
  Two other ways in, both at the **same version as your Flock SDK**: double-click
  `ProtokitePlaytest-<version>.unitypackage` from the release page, or in **Window → Package Manager → + → Add
  package from git URL** enter
  `https://github.com/QwackStack/FlockUnitySDK.git?path=/ProtokitePlaytest~#v<version>` (this route needs Git
  installed). Leave the package out of projects that are not running playtests.
</Tip>

## Step 2: Point the build at the playtest

Protokite finds the playtest from the Flock game version the build sends.

<Steps>
  <Step title="Read the playtest's version">
    Open the test in Protokite. Its **SDK** block shows the playtest's Flock version **ID**. The version's
    **name** is `pt-` followed by the test's ID.
  </Step>

  <Step title="Set Game Version to that version's name">
    In **Flock → Settings → Configuration**, set **Game Version** to `pt-` followed by the test's ID, for
    example `pt-01JABCDEFGHJKMNPQRSTVWXYZ0`. The Flock SDK resolves the name, and **Resolved Version ID**
    shows the ID Protokite showed you.

    <Frame caption="Flock → Settings → Configuration: Game Version set to the playtest's name, and the ID it resolved to.">
      <img src="https://mintcdn.com/qwacks/ByDUWjWU5EEoXzc3/images/protokite/unity/flock-game-version.png?fit=max&auto=format&n=ByDUWjWU5EEoXzc3&q=85&s=f841d08e25bfb5093937b3c3755a4c50" alt="The Flock settings Configuration tab with Game Version set to a pt- name and the Resolved Version ID filled in" width="560" height="218" data-path="images/protokite/unity/flock-game-version.png" />
    </Frame>
  </Step>

  <Step title="Turn playtesting on">
    Choose **Protokite → Playtest → Settings**, or press **Open Playtest Settings** on the Playtesting tab.
    The first time, this creates `Assets/Resources/ProtokitePlaytestSettings.asset` with playtesting off and
    selects it in the Inspector. Tick **Playtesting Enabled**.

    **Protokite Api Url** is already set to production, `https://api-protokite.qwacks.com`; change it only to
    point at a local Protokite such as `http://localhost:8020`. The URL must start with `http://` or `https://`
    and contain no spaces; one that does not is refused rather than tidied up.

    <Frame caption="Protokite → Playtest → Settings: the switch, the Protokite URL, the question put to the player, the feedback form and the recording settings.">
      <img src="https://mintcdn.com/qwacks/ByDUWjWU5EEoXzc3/images/protokite/unity/playtest-settings.png?fit=max&auto=format&n=ByDUWjWU5EEoXzc3&q=85&s=b49ca625524fbc00b6e0d16f38e4e390" alt="The Protokite Playtest settings asset in the Unity Inspector, with Playtesting Enabled ticked" width="720" height="550" data-path="images/protokite/unity/playtest-settings.png" />
    </Frame>
  </Step>
</Steps>

<Warning>
  Set the version's **name**, not the ID Protokite displays. The Flock SDK resolves Game Version by name, so an
  ID typed into Game Version resolves to nothing and the build keeps sending the ID resolved before. The setup
  window in the next step spots a pasted ID and offers to put the right name in for you.
</Warning>

## Step 3: Check your setup

Choose **Protokite → Playtest → Setup Checks And Test Video**, or press **Check Playtest Setup** on the
Playtesting tab. The window checks what a build of this project needs for a playtest. A check that passes
has a green tick and says so:

| The window says | Once |
| - | - |
| Playtesting is turned on | The playtest settings exist and **Playtesting Enabled** is on |
| Protokite API URL is usable | The URL is an `http` or `https` address with a host and no spaces |
| Game Version is a playtest's version | Flock's **Game Version** is a playtest's name, `pt-<test id>`, resolved to the ID a build sends |
| Players built for this platform record video | The build target is 64-bit Windows (x64) |

<Frame caption="Protokite → Playtest → Setup Checks And Test Video. Three checks pass; the fourth fails because this project builds for Android, and offers Open Build Settings.">
  <img src="https://mintcdn.com/qwacks/ByDUWjWU5EEoXzc3/images/protokite/unity/setup-checks.png?fit=max&auto=format&n=ByDUWjWU5EEoXzc3&q=85&s=f2930e900c8ed7ee25c5c2b239ea0760" alt="The Protokite Playtest setup window with three checks passing and the video check failing for an Android build target" width="540" height="360" data-path="images/protokite/unity/setup-checks.png" />
</Frame>

A check that fails has a red mark, says what to change, and has a button that opens the place to change it:
**Open Playtest Settings**, **Open Flock Settings**, **Open Build Settings** (as above), or **Set Game Version
To pt-…** when you pasted the playtest's ID into Game Version. The Game Version is checked with Flock when the window opens and
whenever the Flock settings change; **Check Again** asks again.

"Players built for … record no video" does not stop the playtest: a build for another platform runs
everything else and records no video.

## Step 4: Sign a player in

**A playtest never signs a player in.** Its session starts once a Flock session reaches the server, and a
Flock session starts when your game signs a player in, with **Analytics Enabled** and **Analytics Auto
Start Session** on in **Flock → Settings → Advanced Settings** (or when you call `StartSessionAsync`), and
consent given when **Analytics Require Explicit Consent** is on.

A device sign-in is enough and needs no account:

```csharp theme={null}
await FlockClient.Instance.Authentication.LoginWithDeviceAsync(SystemInfo.deviceUniqueIdentifier);
```

The first time a device signs in, register it with `RegisterWithDeviceAsync` instead; the
[Unity SDK](/sdk/unity#authenticate-a-player) page covers sign-in in full. The package's sample has a
**Sign In With This Device** button that does both, for a build with no sign-in screen of its own.

## Step 5: Press Play

**The build asks its player what the playtest may collect, and collects nothing until they answer.** The
question is drawn over the game as soon as this build's playtest has loaded, and offers four answers:
record the screen and collect play data, the screen only, play data only, or **nothing at all**, which
leaves the build behaving as one with **Playtesting Enabled** off.

<Frame caption="The question a playtest build puts to its player, over the game, before it collects anything.">
  <img src="https://mintcdn.com/qwacks/ByDUWjWU5EEoXzc3/images/protokite/unity/consent-question.png?fit=max&auto=format&n=ByDUWjWU5EEoXzc3&q=85&s=229e514c065a1e41aaab4638c753eb4e" alt="A Unity game showing the playtest's question, What this playtest may collect, with four answers" width="1440" height="810" data-path="images/protokite/unity/consent-question.png" />
</Frame>

It is answered with the mouse. While it is on screen the cursor is shown and free, and it goes back to how
your game had it once the player answers. Nothing is selected when it appears, so your game's own Submit key
presses no answer, and a click in the question's first half second is ignored.

<Note>
  **It is the playtest's own question.** The Flock SDK's **Analytics Require Explicit Consent** is a different
  one, asked by your game in your game's words about your game's analytics. Neither answer moves the other, and
  the question says so in front of the player.
</Note>

The answer is kept on the player's machine and used by every later launch, and each session start carries
`playtest_consent` and `playtest_consent_asked`, so a session with no recording reads as a player who asked
for none rather than a build that went wrong. To be asked again in the editor, press **Forget This
Machine's Answer** in the setup window.

Your game can take the question over from its own menus:

```csharp theme={null}
ProtokitePlaytest.PlaytestConsent             // the answer in force
ProtokitePlaytest.SetPlaytestConsent(ProtokitePlaytestConsentChoice.VideoOnly);   // answer it; NotAnswered asks again
ProtokitePlaytest.AskForPlaytestConsent();    // put the question on screen again
ProtokitePlaytest.IsConsentQuestionOpen       // while it is on screen
```

Turn **Ask The Player For Playtest Consent** off in the playtest settings only where your players are
asked another way, or for a test run with nobody there to answer; the build then collects what the
playtest turns on, and every session says the player was never asked. An answer a player has already given
still counts.

### Watch it run

The Console says what the playtest is doing, each line starting `[Protokite Playtest]`:

```
[Protokite Playtest] The playtest's consent question is on screen; nothing is collected until the player answers it.
[Protokite Playtest] Playtesting is ready: playtest 01JABCDEFGHJKMNPQRSTVWXYZ0 is loaded, with features exception_capturing, heavy_analytics, video_recording and a feedback form.
[Protokite Playtest] Recording video for the playtest to …/recording-….webm.part, at 1280x720 and 15 frames a second (Vp8). It stops for good after 60 minutes of play, before the file passes 1536 MB, or when the game stops it.
[Protokite Playtest] Protokite session 01J… started for this launch, with the player's device id and Flock session 01J….
```

The session then appears on the playtest's **Sessions** page. It ends when the game quits; quitting waits
up to 3 seconds for Protokite to take the end. A sign-out, a new Flock session or restarting the Flock SDK
neither ends nor restarts it: a launch is one session. In code, `ProtokitePlaytest.Status` answers the
same question the log does, and `ProtokitePlaytest.Describe(status)` gives the log's words.

## When something stops the playtest

The Console says why and what to change, once, as a warning.

| Status | Meaning | Fix |
| - | - | - |
| `TurnedOff` | **Playtesting Enabled** is off, or the project has no playtest settings | Turn it on in **Protokite → Playtest → Settings** |
| `ProtokiteApiUrlMissing` | The Protokite API URL is empty | Set **Protokite Api Url** (production is `https://api-protokite.qwacks.com`) |
| `ProtokiteApiUrlUnusable` | No `http://` or `https://`, no host, or a space in it | Correct the URL; it is never trimmed for you |
| `WaitingForFlock` | Everything is set; the Flock SDK has not started yet | Nothing — it goes on once the Flock SDK starts |
| `FetchingPlaytestConfig` | Asking Protokite for this build's playtest | Nothing |
| `PlaytestNotLinked` | Protokite has no playtest for this build's Game Version ID | Set **Game Version** to the playtest's `pt-` name |
| `ProtokiteRefusedApiKey` | Protokite turned down the Flock API key | Check **Api Key** in **Flock → Settings** |
| `PlaytestConfigUnavailable` | Protokite or the network kept failing | Nothing — it is asked again when the next Flock session starts |
| `PlaytestConfigForAnotherVersion` | Protokite answered with another version's playtest, as a proxy dropping headers does | Check what sits between the game and Protokite |
| `PlaytestNoLongerCollecting` | The playtest has closed | Reopen it in Protokite, or point Game Version at a running one |
| `WaitingForPlayerConsent` | The playtest is loaded and the player has not said what it may collect | Nothing — the question is on screen |
| `PlayerRefusedPlaytest` | The player asked for nothing to be collected | Nothing — it is their answer |

A refusal (`PlaytestNotLinked`, `ProtokiteRefusedApiKey`, `PlaytestConfigForAnotherVersion`) is not asked
again until the Flock SDK starts again or the game is relaunched, since the answer would be the same.

## Before you ship

Turn **Playtesting Enabled** off and point **Game Version** back at a release version before you build a
release. A release build still uploads any recording an earlier playtest build on that machine could not
send, so a player's recording is never stranded; with playtesting off, nothing else is recorded or sent.
To take the package out, press **Remove** on the Playtesting tab. Your settings asset stays until you
delete it.

## Tell your players

A playtest build records the player's screen when the playtest turns video on, and sends what they type
into the feedback form. The build asks them first, and does what they answer, but tell your testers
before they play all the same: what is recorded, that it goes to your studio's Protokite playtest, and how
to reach you to have it removed. That question is about this playtest alone — anything your game collects
of its own is still yours to ask about.

<CardGroup cols={2}>
  <Card title="What a playtest collects" icon="video" href="/protokite/unity-features">
    Video, performance windows, exceptions and feedback forms, the C# calls for each, and how to test it all.
  </Card>

  <Card title="Unity SDK" icon="unity" href="/sdk/unity">
    The Flock SDK the playtest runs on: setup, sign-in, and your game's data.
  </Card>
</CardGroup>
