6labs >

6labs SDK for Unity

This section explains how to integrate the 6labs SDK into your Unity apps.

Prerequisites

  • 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
  • Your Unity project must meet the following minimum deployment targets:
    • iOS — iOS 15 or higher
    • tvOS — tvOS 15 or higher
    • Android — API level 23 (Android 6.0 Marshmallow) 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:

  1. Download the latest version v3.9.0 of the 6labs SDK for Unity.
  2. Import the package into your Unity project:
    • Click on Assets > Import Package > Custom Package.
    • Select the downloaded .unitypackage file from your system.
    • Click on Import.

2. Start Observing Gameplay

Use the Start() method to start observing gameplay, as illustrated below:

using SixLabs.SDK;

SixLabsSDK.Instance.Start( inGameId: "<optional_player_in_game_id>",
developerPayload: "<optional_developer_payload_here>",
callbackOnComplete: (sdkResponse, errorMessage) => {
// sdkResponse == SdkResponse.SUCCESS means Start() completed successfully
// handle result
// SixLabsSDK.Instance.CurrentState gives you the SDK's current state

}
);

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.

Important Information

  • If 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.
  • 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, Start() invokes callbackOnComplete with ERROR_NOT_SUPPORTED instead.

Reference

The following is the method reference for the Start() method.

Method Signature

public void Start(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:

  • Acquisition channel
  • Campaign ID
  • User segment (e.g., new, returning, whale)
  • A/B test variant (e.g., variant_a, variant_b) — split users into cohorts and compare gameplay metrics across them in the 6labs dashboard.
  • Internal reference identifiers
callbackOnComplete Action<SdkResponse, string> No Invoked once the call completes, whether it succeeds or fails. See Callback below.

Callback

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.

Note


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 inGameId was provided during Start(), calling SetInGameId() will overwrite the previously set value for the current session.

Reference

The following is the method reference for the SetInGameId() method.

Method Signature

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>"
);

Reference

The following is the method reference for the SendGameEvent() method.

Method Signature

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

Start() begins observing gameplay for a new session. Use Pause(), Resume(), and Stop() to control that session afterward based on your requirements.

5.1 Pause

Use the Pause() method to pause gameplay observation.

SdkResponse result = SixLabsSDK.Instance.Pause();

Requires: SDK_STATE_CAPTURING. See SDK States and Response Codes for the full list of states and response codes.

Important Information

  • Pauses the gameplay observation.
  • You can call Resume() again later to resume gameplay observation.

Reference

The following is the method reference for the Pause() method.

Method Signature

public SdkResponse Pause()

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 SDK States and Response Codes for the full list of states and response codes.

5.2 Resume

Use the Resume() method to continue a session that was previously paused with Pause().

SixLabsSDK.Instance.Resume( callbackOnComplete: (sdkResponse, errorMessage) => {
// sdkResponse == SdkResponse.SUCCESS means Resume() completed successfully
// handle result
// SixLabsSDK.Instance.CurrentState gives you the SDK's current state

}
);

Requires: SDK_STATE_PAUSED. See SDK States and Response Codes for the full list of states and response codes.

Reference

The following is the method reference for the Resume() method.

Method Signature

public void Resume(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 below.

Callback

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.

Note

5.3 Stop

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.

SixLabsSDK.Instance.Stop( callbackOnComplete: (sdkResponse, errorMessage) => {
// sdkResponse == SdkResponse.SUCCESS means Stop() completed successfully
// handle result
// SixLabsSDK.Instance.CurrentState gives you the SDK's current state

}
);

Requires: SDK_STATE_CAPTURING or SDK_STATE_PAUSED. See SDK States and Response Codes for the full list of states and response codes.

Reference

The following is the method reference for the Stop() method.

Method Signature

public void Stop(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 below.

Callback

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.

Note


6. SDK States and Response Codes

The following are the SDK's states and response codes:

  • You can check the current SDK state at any time using 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.
  • The callbackOnComplete callback is called asynchronously.

6.1 States

public enum SdkState {
SDK_STATE_IDLE = 100,
SDK_STATE_CAPTURING = 101,
SDK_STATE_STOPPING = 102,
SDK_STATE_PAUSED = 103

}
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.2 Response Codes

public enum SdkResponse {
SUCCESS = 0,
ERROR_STATE_NOT_IDLE = 1000,
ERROR_STATE_NOT_CAPTURING = 1001,
ERROR_NOT_SUPPORTED = 1002,
ERROR_STATE_NOT_PAUSED = 1003,
ERROR_SESSION_FAILED = 1004

}
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.
×

Table of Contents

6labs SDK for Unity

Table of Contents

Text copied to clipboard
Questions? Please reach out to us at dev-support@6labs.ai