This section explains how to integrate the 6labs SDK into your Unity apps.
The 6labs SDK is included as a Unity package file.
Add the module to your Unity project:
v3.9.0 of the 6labs SDK for Unity..unitypackage file from your system.Use the Start() method to start observing gameplay, as
illustrated
below:
Requires: SDK_STATE_IDLE. If the SDK is paused, Start() returns ERROR_STATE_NOT_IDLE. Use Resume() to continue the paused session. See SDK States and Response Codes for the full list of states and response codes.
inGameId is not passed, the observed session may be discarded and will not be used for AI analysis. Without it, sessions cannot be attributed to a player, which is required for downstream insights.Start() invokes callbackOnComplete with ERROR_NOT_SUPPORTED instead.The following is the method reference for the
Start() method.
| Parameter | Type | Required | Description |
|---|---|---|---|
inGameId |
string |
No | An optional but recommended user identifier. If omitted, the session may be discarded and will not be used for AI analysis. |
developerPayload
|
string |
No | Optional developer-defined metadata associated with the session. This value is forwarded as-is with the session request and can be used to attach custom tracking or contextual information. Providing richer developerPayload can significantly improve AI-powered analysis and session understanding. See the Developer Payload Example page for detailed use cases and JSON examples.Example:
|
callbackOnComplete |
Action<SdkResponse, string> |
No | Invoked once the call completes, whether it succeeds or fails. See Callback below. |
The callback is asynchronous and returns the SdkResponse and errorMessage. errorMessage is empty on success and describes the failure otherwise.
| Response | Description |
|---|---|
SUCCESS |
The session started successfully. |
ERROR_STATE_NOT_IDLE |
The SDK wasn't in SDK_STATE_IDLE — a session is already running, it's paused, or a previous one is still stopping. |
ERROR_NOT_SUPPORTED |
The current platform doesn't support observing gameplay at all — currently only the Unity Editor. |
ERROR_SESSION_FAILED |
The request was accepted, but the observation session could not start and the SDK returned to SDK_STATE_IDLE. This may occur due to session creation failure, device limitations, an outdated SDK version, network issues, or any other initialization failure. |
Use the SetInGameId() method to associate a player's in-game ID with an existing observation session. This is typically required when the SDK is initialized before the user account is created, and you want to link the signed-in user to the session that is already in progress.
inGameId was provided during Start(), calling SetInGameId() will overwrite the previously set value for the current session.The following is the method reference for the
SetInGameId() method.
| Parameter | Type | Required | Description |
|---|---|---|---|
inGameId |
string |
Yes | The player's in-game identifier to associate with the current session. |
Use the SendGameEvent() method to log a custom gameplay event during an active observation session. Events are attached to the session and can be used to correlate specific gameplay moments during analysis.
The following is the method reference for the
SendGameEvent() method.
| Parameter | Type | Required | Description |
|---|---|---|---|
eventName |
string |
Yes | The name of the custom event to log. |
eventDataJson |
string |
Yes | A JSON-encoded string containing additional data associated with the event. |
| Value | Description |
|---|---|
true |
The event was accepted and queued for upload. |
false |
The event was rejected, for example if eventName is empty. |
Start() begins observing gameplay for a new session. Use
Pause(),
Resume(), and
Stop() to control that session afterward based on your requirements.
Use the Pause() method to pause gameplay observation.
Requires: SDK_STATE_CAPTURING. See SDK States and Response Codes for the full list of states and response codes.
Resume()
again later to resume gameplay observation.
The following is the method reference for the
Pause() method.
| Value | Description |
|---|---|
SUCCESS |
The call was accepted and acted on. |
ERROR_STATE_NOT_CAPTURING |
Returned when the SDK is not in SDK_STATE_CAPTURING — for example if gameplay observation is not running, the session is already paused, or a stop is already in progress. See SDK States and Response Codes for the full list of states and response codes. |
Use the Resume() method to continue a session that was previously paused with Pause().
Requires: SDK_STATE_PAUSED. See SDK States and Response Codes for the full list of states and response codes.
The following is the method reference for the
Resume() method.
| Parameter | Type | Required | Description |
|---|---|---|---|
callbackOnComplete |
Action<SdkResponse, string> |
No | Invoked once the call completes, whether it succeeds or fails. See Callback below. |
The callback is asynchronous and returns the SdkResponse and errorMessage. errorMessage is empty on success and describes the failure otherwise.
| Response | Description |
|---|---|
SUCCESS |
The session resumed successfully. |
ERROR_STATE_NOT_PAUSED |
The SDK wasn't in SDK_STATE_PAUSED, so there was no paused session to continue. |
ERROR_SESSION_FAILED |
The request was accepted, but the paused session could not resume and the SDK returned to SDK_STATE_IDLE. This may occur due to a session or runtime failure, network issues, or another failure that prevents the session from resuming. |
Use the Stop() method to permanently end the current session. Unlike Pause(), a stopped session cannot be continued with Resume() — starting a new session requires calling Start() again.
Requires: SDK_STATE_CAPTURING or SDK_STATE_PAUSED. See SDK States and Response Codes for the full list of states and response codes.
The following is the method reference for the
Stop() method.
| Parameter | Type | Required | Description |
|---|---|---|---|
callbackOnComplete |
Action<SdkResponse, string> |
No | Invoked once the call completes, whether it succeeds or fails. See Callback below. |
The callback is asynchronous and returns the SdkResponse and errorMessage. errorMessage is empty on success and describes the failure otherwise.
| Response | Description |
|---|---|
SUCCESS |
The call was accepted and the session has ended. |
ERROR_STATE_NOT_CAPTURING |
The SDK wasn't in SDK_STATE_CAPTURING or SDK_STATE_PAUSED, so there was no active or paused session to stop. |
The following are the SDK's states and response codes:
SixLabsSDK.Instance.CurrentState.Start(), Pause(), Resume(), and Stop() can only be called from valid SDK states. Calling an operation from an invalid state returns an error.Pause() returns an SdkResponse directly. Start(), Resume(), and Stop() return their result through the optional callbackOnComplete callback.callbackOnComplete callback is called asynchronously.| State | Value | Description |
|---|---|---|
SDK_STATE_IDLE |
100 |
The SDK is not observing gameplay. This is the default state and the state returned to after a session stops or fails to start. |
SDK_STATE_CAPTURING |
101 |
The SDK is actively observing gameplay. This includes the active session and background processing such as buffering and uploading data. |
SDK_STATE_STOPPING |
102 |
The session is stopping. The SDK is finishing any remaining processing before returning to SDK_STATE_IDLE. |
SDK_STATE_PAUSED |
103 |
The session is paused. Gameplay observation is temporarily stopped, but the session remains open and previously observed data can continue uploading. |
| Response | Value | Description |
|---|---|---|
SUCCESS |
0 |
The operation was accepted and completed successfully. For Stop(), the session has ended. |
ERROR_STATE_NOT_IDLE |
1000 |
Start() was called while the SDK was not idle. A session may already be running, paused, or stopping. |
ERROR_STATE_NOT_CAPTURING |
1001 |
Pause() or Stop() was called when the SDK was not observing. Stop() can also end a paused session. |
ERROR_NOT_SUPPORTED |
1002 |
Start() was called on a platform where gameplay observation is not supported, such as the Unity Editor. |
ERROR_STATE_NOT_PAUSED |
1003 |
Resume() was called when the SDK was not paused. Use Start() to begin a new session when the SDK is idle. |
ERROR_SESSION_FAILED |
1004 |
The request was accepted, but observation could not start and the SDK returned to SDK_STATE_IDLE. For example, session creation may fail due to a low-end device, an outdated SDK version, network issues, or another initialization issue. This error is delivered through callbackOnComplete, not as an immediate rejection. |