Laya Unity: a Unity-native SDK for System One decisions in games
Backend-independent Unity client for local Laya servers and TypeSafe-compatible endpoints. Game state in, Choice/Score/Noul out; transport-first, no embedded weights.
# Laya Unity
Laya Unity is a community Unity SDK for System One decision models.
```text
game state
↓
Choice / Score / Noul
↓
Laya / compatible backend
↓
structured decision
```
It provides a Unity-native, backend-independent client for local Laya-compatible servers and TypeSafe-compatible System One endpoints. Version 0.1 is deliberately transport-first: it does not embed ONNX, a tokenizer, Python, or model weights.
> [!IMPORTANT]
> This project is an early community SDK, not production-ready software and not affiliated with Laya or TypeSafe.
## Install
In Unity 2022.3 LTS or newer, open **Window → Package Manager**, choose **Add package from git URL**, and enter:
```text
https://github.com/0x440-1me/laya-unity.git
```
The package depends on Unity's maintained `com.unity.nuget.newtonsoft-json` package, currently pinned to `3.2.2`.
## Quick start: local Laya
```csharp
using System.Threading;
using Laya.Unity;
using Laya.Unity.Questions;
using UnityEngine;
var client = LayaClient.CreateLocal("http://127.0.0.1:8000");
var result = await client.SystemOneAsync(
state: new
{
health = 25,
enemyDistance = 4.2f,
ammo = 2
},
questions: QuestionSet.Create(
("action", Choice.Create(
"What should the NPC do?",
("attack", "Engage the enemy"),
("retreat", "Move toward safety"),
("wait", "Hold position"))),
("danger", Score.Create(
"How dangerous is the situation?",
"safe", "moderate danger", "extreme danger")),
("flee", Noul.Create("Should the NPC flee?"))),
cancellationToken: CancellationToken.None);
var action = result.GetChoice("action");
Debug.Log($"{action.Choice} ({action.Confidence:P0})");
```
The default local endpo