6labs SDK for Unity
This guide covers integrating the 6labs SDK into your Unity game: importing the package, starting and controlling observation, and sending gameplay events.
Supported Platforms
The 6labs SDK for Unity observes gameplay on the following platforms:
- iOS — iOS 15 or higher
- Android — API level 23 (Android 6.0 Marshmallow) or higher
- Windows 11 with DirectX 12
Prerequisites
Before integrating the 6labs SDK, ensure your development environment and project meet the following requirements:
- Unity 2021 LTS or later is required. Earlier versions may work but are not actively supported.
- Apple platforms only — Ensure the following tools are installed on your development machine:
- Xcode 26.2 or higher
- CocoaPods 1.12.0 or higher
1. Download and Import the Module
The 6labs SDK is included as a Unity package file.
Add the module to your Unity project:
- Download the latest version
v4.0.0of the 6labs SDK for Unity. - Import the package into your Unity project:
- Click on Assets > Import Package > Custom Package.
- Select the downloaded
.unitypackagefile from your system. - Click on Import.
2. Start Observing Gameplay
Use the StartSession() method to start observing gameplay, as
illustrated
below:
using SixLabs.SDK;
SixLabsSDK.Instance.StartSession(
inGameId: "<optional_player_in_game_id>",
developerPayload: "<optional_developer_payload_here>",
callbackOnComplete: (sdkResponse, errorMessage) => {
// sdkResponse == SdkResponse.SUCCESS means StartSession() completed successfully
// handle result
// SixLabsSDK.Instance.CurrentState gives you the SDK's current state
}
);
Important Information
- If
inGameIdis 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. - Ensure that you obtain user consent before observing gameplay. The SDK does not automatically request permission; consent handling must be implemented in your game logic.
- As a suggested best practice, you may include a disclosure of gameplay observation in your game’s EULA or privacy policy.
- Ensure your app has the necessary internet permission enabled for your target platform.
- The SDK does not function within the
Unity Editor. To properly test
it, you need to create a
platform-specific build and run
it on a physical device. In the Editor,
StartSession()invokescallbackOnCompletewithERROR_NOT_SUPPORTEDinstead.
ReferenceStartSession()
public void StartSession(
string inGameId = null,
string developerPayload = null,
Action<SdkResponse, string> callbackOnComplete = null)
Parameters
| 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 Parameters. |
Callback Response
The callback is asynchronous and provides the result through sdkResponse and errorMessage.
| 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. Use ResumeSession() to continue the paused session. |
ERROR_NOT_SUPPORTED |
StartSession() was called on a platform where gameplay observation is not supported, such as 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. |
3. Set In-Game ID
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.
SixLabsSDK.Instance.SetInGameId("<player_in_game_id>");
Note
- If
inGameIdwas provided duringStartSession(), callingSetInGameId()will overwrite the previously set value for the current session.
ReferenceSetInGameId()
public void SetInGameId(string inGameId)
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
inGameId |
string |
Yes | The player's in-game identifier to associate with the current session. |
4. Send Game Events
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.
bool result = SixLabsSDK.Instance.SendGameEvent(
eventName: "<event_name>",
eventDataJson: "<event_data_as_json>"
);
ReferenceSendGameEvent()
public bool SendGameEvent(
string eventName,
string eventDataJson)
Parameters
| 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. |
Returns
| Value | Description |
|---|---|
true |
The event was accepted and queued for upload. |
false |
The event was rejected, for example if eventName is empty. |
5. Advanced Controls
StartSession() begins observing gameplay for a new session. Use
PauseSession(),
ResumeSession(), and
StopSession() to control that session afterward based on your requirements.
5.1 PauseSession
Use the PauseSession() method to pause gameplay observation.
SdkResponse result = SixLabsSDK.Instance.PauseSession();
Important Information
- Pauses the gameplay observation.
- You can call
ResumeSession()again later to resume gameplay observation.
ReferencePauseSession()
public SdkResponse PauseSession()
Returns
| 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 Session Lifecycle for the full list of states and response codes. |
5.2 ResumeSession
Use the ResumeSession() method to continue a session that was previously paused with PauseSession().
SixLabsSDK.Instance.ResumeSession(
callbackOnComplete: (sdkResponse, errorMessage) => {
// sdkResponse == SdkResponse.SUCCESS means ResumeSession() completed successfully
// handle result
// SixLabsSDK.Instance.CurrentState gives you the SDK's current state
}
);
ReferenceResumeSession()
public void ResumeSession(Action<SdkResponse, string> callbackOnComplete = null)
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
callbackOnComplete |
Action<SdkResponse, string> |
No | Invoked once the call completes, whether it succeeds or fails. See Callback Parameters. |
Callback Response
The callback is asynchronous and provides the result through sdkResponse and errorMessage.
| 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. |
5.3 StopSession
Use the StopSession() method to permanently end the current session. Unlike PauseSession(), a stopped session cannot be continued with ResumeSession() — starting a new session requires calling StartSession() again.
SixLabsSDK.Instance.StopSession(
callbackOnComplete: (sdkResponse, errorMessage) => {
// sdkResponse == SdkResponse.SUCCESS means StopSession() completed successfully
// handle result
// SixLabsSDK.Instance.CurrentState gives you the SDK's current state
}
);
ReferenceStopSession()
public void StopSession(Action<SdkResponse, string> callbackOnComplete = null)
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
callbackOnComplete |
Action<SdkResponse, string> |
No | Invoked once the call completes, whether it succeeds or fails. See Callback Parameters. |
Callback Response
The callback is asynchronous and provides the result through sdkResponse and errorMessage.
| 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. |
6. Session Lifecycle
The SDK moves through the following states. Which methods you can call, and what they return, depends on the current state:
- You can check the current SDK state at any time using
SixLabsSDK.Instance.CurrentState. StartSession(),PauseSession(),ResumeSession(), andStopSession()can only be called from valid SDK states. Calling an operation from an invalid state returns an error.PauseSession()returns anSdkResponsedirectly.StartSession(),ResumeSession(), andStopSession()return their result through the optionalcallbackOnCompletecallback.- The
callbackOnCompletecallback is called asynchronously.
6.1 Callback Parameters
The callback is of type Action<SdkResponse, string> and receives the following two parameters:
| Parameter | Type | Description |
|---|---|---|
sdkResponse |
SdkResponse |
The outcome of the call. See Response Codes. |
errorMessage |
string |
Empty on success; describes the failure otherwise. |
6.2 States
The following states describe the SDK's lifecycle. The current state determines which operations the SDK accepts.
| 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. |
6.3 Response Codes
The following response codes indicate the outcome of a lifecycle method call.
| Response | Value | Raised by | What to do |
|---|---|---|---|
SUCCESS |
0 |
All | Nothing — the call was accepted and completed. For StopSession(), the session has ended. |
ERROR_STATE_NOT_IDLE |
1000 |
StartSession() |
A session is already running, paused, or still stopping. Check CurrentState; call ResumeSession() if it is paused. |
ERROR_STATE_NOT_CAPTURING |
1001 |
PauseSession(), StopSession() |
The SDK is not observing. Safe to ignore when the call comes from a lifecycle hook that can fire without a session. StopSession() can also end a paused session. |
ERROR_NOT_SUPPORTED |
1002 |
StartSession() |
Gameplay observation is not available here — currently the Unity Editor. Return early; do not retry. |
ERROR_STATE_NOT_PAUSED |
1003 |
ResumeSession() |
The SDK is not paused. Call StartSession() instead when the state is SDK_STATE_IDLE. |
ERROR_SESSION_FAILED |
1004 |
StartSession(), ResumeSession() |
The request was accepted but the session could not start, and the SDK is back in SDK_STATE_IDLE. It arrives through callbackOnComplete, not as an immediate rejection. Log errorMessage and retry at the next natural break; common causes are a low-end device, an outdated SDK version, and network issues. |
