# Unity Session Replay installation - Docs

1.  1

    ## Install the SDK

    Required

    Requires **Unity 2021.3 LTS** or later with **.NET Standard 2.1** API compatibility level.

    In the Unity Editor, open **Window > Package Manager**, click the **+** button, select **Add package from git URL**, and enter:

    text

    PostHog AI

    ```text
    https://github.com/PostHog/posthog-unity.git?path=com.posthog.unity
    ```

    See the [Unity SDK docs](/docs/libraries/unity.md) for other installation methods and full setup instructions.

2.  2

    ## Enable session recordings in project settings

    Required

    Go to your PostHog [Project Settings](https://us.posthog.com/settings/project-replay) and enable **Record user sessions**. Session recordings will not work without this setting enabled.

3.  3

    ## Configure PostHog with session replay

    Required

    Add `SessionReplay = true` to your PostHog configuration. You can also configure it via the Unity Inspector in **Edit > Project Settings > PostHog**.

    GameManager.cs

    PostHog AI

    ```csharp
    using PostHogUnity;
    using PostHogUnity.SessionReplay;
    PostHog.Setup(new PostHogConfig
    {
        ApiKey = "<ph_project_token>",
        Host = "https://us.i.posthog.com",
        SessionReplay = true,
        SessionReplayConfig = new PostHogSessionReplayConfig
        {
            // Min seconds between captures (default: 1.0)
            ThrottleDelaySeconds = 1.0f,
            // JPEG quality 1-100 (default: 80)
            ScreenshotQuality = 80,
            // Resolution scale 0.1-1.0 (default: 0.75)
            ScreenshotScale = 0.75f,
            // Record HTTP request metadata (default: true)
            CaptureNetworkTelemetry = true,
            // Record console logs (default: false)
            CaptureLogs = false,
            // Log, Warning, or Error (default: Error)
            MinLogLevel = SessionReplayLogLevel.Error,
        }
    });
    ```

    **How it works**

    The Unity SDK captures screenshots using `AsyncGPUReadback` to avoid blocking the main thread. It also records touch/mouse input, network requests, and console logs alongside each screenshot. Session replay requires `AsyncGPUReadback` support and is automatically disabled on WebGL.

    **No masking support**

    The Unity SDK uses screenshot-based capture. Unlike web and mobile SDKs, there is **no built-in masking** for text, images, or other UI elements. Screenshots may contain sensitive information. Make sure you are not displaying personal data or secrets on screen during recorded sessions.

    **Limitations**

    The Unity SDK reads the **Record user sessions** toggle from PostHog project settings, but more granular options like `CaptureNetworkTelemetry`, `CaptureLogs`, and sampling are **not** remotely configurable and must be set locally in code at initialization time.

4.  4

    ## Watch session recordings

    Recommended

    Visit your site or app and interact with it for at least 10 seconds to generate a recording. Navigate between pages, click buttons, and fill out forms to capture meaningful interactions.

    [Watch your first recording →](/replay/home.md)

5.  5

    ## Next steps

    Recommended

    Now that you're recording sessions, continue with the resources below to learn what else Session Replay enables within the PostHog platform.

    | Resource | Description |
    | --- | --- |
    | [Watching recordings](/docs/session-replay/how-to-watch-recordings.md) | How to find and watch session recordings |
    | [Privacy controls](/docs/session-replay/privacy.md) | How to mask sensitive data in recordings |
    | [Network recording](/docs/session-replay/network-recording.md) | How to capture network requests in recordings |
    | [Console log recording](/docs/session-replay/console-log-recording.md) | How to capture console logs in recordings |
    | [More tutorials](/docs/session-replay/tutorials.md) | Other real-world examples and use cases |

### Community questions

Ask a question

### Was this page useful?

HelpfulCould be better