First Inference in Unity¶
Unpack a Tryll release, drop the package and the server into your Unity
project, configure one project setting, and watch a single Generate
node print its answer to a text element during Play Mode — no chat UI
required.
What you'll build¶
A scene with a TryllAgentComponent on a GameObject that, on Start,
connects to a locally-spawned Tryll server, downloads a model on first
run, sends the prompt "In one sentence: what is Tryll?", and streams
the answer into a UI Text element.
Before you start¶
- Unity 6 (6000.x) or later, with a blank 3D project.
- ~5 GB free disk space for the auto-downloaded model and a working internet connection on first run.
- Familiarity with creating GameObjects, adding components, and writing a short C# MonoBehaviour.
You do not need to build anything from source — the distribution ships pre-generated FlatBuffers bindings.
Step 1 — Get the distribution¶
- Download
tryll-<version>.7zfrom the releases page and extract it somewhere temporary (e.g.C:\Downloads\tryll\). -
You'll get three sibling folders:
tryll/ ├── server/ │ ├── tryll_server.exe │ ├── llama.dll, ggml*.dll, ggml-vulkan.dll │ └── data/ │ ├── server-config.json │ ├── models.json │ ├── default-canned-responses.txt │ └── default-guardrail-patterns.txt ├── UnityPlugin/ │ ├── package.json │ ├── Runtime/ │ └── Editor/ └── UnrealPlugin/ └── ...
The archive ships no model weights — the server lazy-downloads
whatever the graph references, into .app-data/models/ next to the exe.
Step 2 — Install the Unity package¶
Copy both the server/ and UnityPlugin/ folders into your Unity
project as a top-level Tryll/ folder:
<YourProject>/
├── Assets/
├── Packages/
│ └── manifest.json
├── Tryll/
│ ├── tryll_server.exe
│ ├── llama.dll, ggml*.dll, ggml-vulkan.dll
│ ├── data/
│ └── UnityPlugin/ <-- copy UnityPlugin/* here
│ ├── package.json
│ ├── Runtime/
│ └── Editor/
└── <YourProject>.sln
Then register the package in Packages/manifest.json:
Save the file. Unity will import the package; you should see no compile errors.
Add this to .gitignore to keep the model cache out of source control:
Why one Tryll/ folder?
Keeping the server binary and the package together means one path to set in Project Settings, one entry to gitignore, and one folder to update on a new release.
Step 3 — Configure Tryll Client in Project Settings¶
Open Edit → Project Settings → Tryll Client and set:
| Setting | Value | Why |
|---|---|---|
| Auto Launch Server | true (default) |
TryllClient spawns the server on Awake in standalone builds. |
| Editor Server Exe Path | Tryll/tryll_server.exe |
Resolves relative to the Unity project root. Used by the editor (Play Mode and the Chat Window). |
| Build Server Exe Path | tryll_server.exe (default) |
Used in packaged builds, relative to the game exe. |
| Allow Auto Model Downloading | true |
First-inference convenience: CreateAgent will download missing models automatically. |
| Game Name | e.g. my-game |
Short slug sent to the server on every session for telemetry grouping. Please fill it for convenience. |
Settings are saved to Assets/Resources/TryllRuntimeSettings.asset
(created on first access).
Allow Auto Model Downloading is a development flag
It removes friction during the first-inference loop, but it lets a
CreateAgent call block for minutes while a model downloads. For
shipped builds, drive downloads explicitly with the DownloadModel
API and a progress UI. See
Enable Auto Model Downloading.
Step 4 — Set up the scene¶
- Create a new empty GameObject — call it
TryllDemo. - Add a Tryll Agent Component (
Add Component → Tryll → Tryll Agent Component). - In the Inspector, expand Inline Graph Description:
- Under Nodes, add one entry. Set Name =
answer, Type =Generate. Leave Params empty for now. The node's Default Exit field can be left blank — an empty exit routes the turn to END automatically. - Set Start Node =
answer. - Set Default Model Name to a catalog entry — spelling must
match
Tryll/data/models.jsonexactly. Recommended:Gemma 3 4B Instruct (Q4_K_M)(~3 GB download). Smaller / quicker:Llama 3.2 3B Instruct (Q4_K_M)(~2 GB download).
- Under Nodes, add one entry. Set Name =
- Leave Workflow Asset empty — the inline description is used when no asset is assigned.
- Un-check Auto Create On Connect — this tutorial wires the lifecycle explicitly so the session is configured before the agent is created.
- Add a UI → Text (TMP) element to your scene — name it
AnswerText. - Create a C# script
TryllDemo.csand attach it to the same GameObject:
using UnityEngine;
using TMPro;
using Tryll.Client;
public class TryllDemo : MonoBehaviour
{
public TMP_Text AnswerText;
private TryllAgentComponent _agent;
private string _accumulated = "";
void Start()
{
_agent = GetComponent<TryllAgentComponent>();
_agent.OnAnswerText.AddListener((text, isDelta, isFinal) =>
{
_accumulated = isDelta ? _accumulated + text : text;
AnswerText.text = _accumulated;
});
_agent.OnTurnComplete.AddListener((status, debugInfo, tokens) =>
{
if (status != TryllTurnStatus.Success)
Debug.LogError($"Turn failed: {status}");
});
_agent.OnError.AddListener(error =>
Debug.LogError($"Tryll error: {error}"));
_agent.OnAgentCreated.AddListener(() =>
_agent.SendMessage("In one sentence: what is Tryll?"));
var client = TryllClient.Instance;
client.ConfigureSessionComplete += err =>
{
if (!err.IsOk) { Debug.LogError($"ConfigureSession failed: {err}"); return; }
_agent.CreateAgent();
};
client.Connect();
client.ConfigureSession(TryllInferenceEngine.LlamaCpp,
TryllRuntimeSettings.Load().AllowAutoModelDownloading);
}
}
- Assign the
AnswerTextreference in the Inspector.
Step 5 — Test without entering Play Mode¶
Before pressing Play, use the Chat Window to verify your setup is working:
- Open Window → Tryll → Chat.
- Confirm the Tryll Settings field shows your
TryllRuntimeSettingsasset (auto-found). - Drag the
TryllDemoGameObject's Tryll Agent Component into the Agent Component slot. - Click Start — the window launches the server, connects, and creates the agent. The status label turns green: Ready.
- Type a message and press Enter. You should see a streamed reply.
- Click Stop when done.
See Test an Agent in the Editor for the full walkthrough including troubleshooting.
Step 6 — Enter Play Mode¶
Press Play.
On the first run you'll see:
- A brief pause while the server starts and the client connects.
- A longer pause (minutes, depending on your network) while the model
downloads — watch the Console for
[Tryll]-prefixed progress lines. - The model loads from disk (a few seconds the first time it is used in a session).
- The answer streams into
AnswerText.
Subsequent runs skip the download and load steps — the model stays in
the server process, and .app-data/models/ persists across Play Mode
sessions.
Where to see what's happening¶
Open the Console window and filter by [Tryll]:
| Prefix | Source | Useful for |
|---|---|---|
[TryllClient] |
TryllClient singleton |
Connection attempts, session config, agent lifecycle. |
[TryllAgent] |
TryllAgentComponent |
Agent created/destroyed, DownloadProgress, errors. |
[TryllServer] |
tryll_server.exe stdout (re-emitted by the client) |
Listening on 0.0.0.0:9100, model load lines, server errors. |
A rotating server log is also written to
Tryll/.app-data/logs/tryll.log (production log mode is the default
in the shipped server-config.json).
What you built¶
- A session connected to a Tryll server the client spawned for you.
- One agent with a one-node graph.
- Model output surfaced as
OnAnswerTextevents (setstream="true"on the node'sParamsfor token-by-token chunks instead of a single full-reply frame).
Where to go next¶
- Test an Agent in the Editor — iterate on your workflow without entering Play Mode.
- How-to Guides — RAG, tool calls, guardrails, model management.
- Concepts — the mental model behind the graph abstraction.
- Unity Client API Reference — complete class-level reference.
- Enable Auto Model Downloading — production-friendly download flow with explicit progress.
Troubleshooting¶
- Compile errors on import — check that
Tryll/UnityPlugin/Runtime/Generated/contains.csfiles. If that folder is empty, the distribution was packaged without the FlatBuffers step; contact support or re-download. [TryllServer] Failed to find server exe—Editor Server Exe Pathdoesn't point at your copy. Remember it resolves relative to the Unity project root; with the layout above it should beTryll/tryll_server.exe.- Stuck at connecting — the server crashed or didn't start in time.
Check the Console for
[TryllServer]lines andTryll/.app-data/logs/tryll.logas a fallback. ConfigureSessionfails — usually a server-side error readingmodels.jsonor initialising the inference engine. Check[TryllServer]Console output.CreateAgenthangs for minutes — the model is downloading because Allow Auto Model Downloading is on. Watch the Console forDownloadProgresslines, or pre-download from a small UI using theDownloadModelAPI instead.OnErrorfires duringCreateAgent— read the error message. Common causes:Default Model Namedoesn't match any entry inmodels.json, or a route targets a node that doesn't exist.- Nothing appears in
AnswerText— confirmOnAnswerTextis wired and that_accumulatedis being assigned toAnswerText.text. With the defaultstream="false",OnAnswerTextfires once with the full reply immediately beforeOnTurnComplete.