Build settings
- Switch the platform to Web.
- In Publishing Settings, set Compression Format to Disabled. Compressed
.gz,.brand.unitywebfiles are not accepted. - Build, then ZIP the output with
index.htmlat the root, includingBuild/*.loader.js,*.framework.js,*.wasm,*.dataandTemplateData.
A single-player Unity game needs nothing else.
Relay rooms with PeerlessBridge
The Unity integration contains Assets/PeerlessBridge.cs, Assets/Plugins/WebGL/Peerless.jslib and peerless-unity.js.
- Copy both assets into your project and attach one
PeerlessBridgeto an active GameObject with a unique, stable name. - Copy
peerless-sdk.jsandpeerless-unity.jsbeside the exportedindex.htmland load them before the Unity loader:
<script src="peerless-sdk.js"></script>
<script src="peerless-unity.js"></script>- Subscribe to the bridge before
Startand send events after you receivejoined:
public class RoomClient : MonoBehaviour
{
public PeerlessBridge bridge;
void Awake()
{
bridge.Message += json => Debug.Log(json); // ready, joined, presence, event, disconnect, error
}
public void Move(float x, float y)
{
bridge.SendEvent("{\"name\":\"move\",\"data\":{\"x\":" + x + ",\"y\":" + y + "}}");
}
}Each message is a JSON envelope with type and data. A solo launch reports ready with room: null and opens no socket. Destroying the component leaves the room.
Upload settings
Choose Unity Web and keep index.html as the entrypoint. Enable Peerless rooms only when you include the bridge.