콘텐츠로 이동
Get Started

Unity SDK Setup

이 콘텐츠는 아직 번역되지 않았습니다.

The FirstLook Unity SDK lets you interface with FirstLook from your Unity game. The SDK supports Steam and Google Play authentication, in-game surveys, session tracking, custom events, and custom duration events.

The SDK ships as two Unity packages:

  • com.pragma.firstlook.core is the required runtime package for authentication, sessions, analytics, and survey transport.
  • com.pragma.firstlook.ui is an optional native survey UI package built on top of core.

The main integration surface is FirstLookClient, which you initialize through FirstLookBootstrap.InitializeWithSettings(...). If you install the UI package, FirstLookSurveyPresenter is the main packaged entry point for native in-game survey rendering.

For this setup guide, we will assume you have a Unity project named MyGame.

  1. Acquire the FirstLook Unity SDK from the admin dashboard. Download
SDK

  2. Set up your Steam game in FirstLook. See the Steam Integration.
  3. Invite a test player to your playtest with their Steam account linked. See the Inviting Players.

  4. Collect the values you’ll need for setup:

    • gameSlug from your FirstLook game settings
    • clientUrl from your FirstLook domain settings
    • Your Steam App ID

    To find your client URL, check your domain from your FirstLook settings: Client URL

Now that you’ve acquired the FirstLook Unity SDK and set up your game in FirstLook, install the packages into your Unity project.

  1. Unzip FirstLookUnitySdk.zip (the file you downloaded from the admin dashboard) to extract the com.pragma.firstlook.core and com.pragma.firstlook.ui package tarballs.

  2. Open Window > Package Manager in the Unity Editor.
  3. Select + > Add package from tarball... and install the com.pragma.firstlook.core tarball you extracted from the zip. This is the required package.

  4. Repeat the same Add package from tarball... flow for com.pragma.firstlook.ui if you want the packaged native in-game survey UI. If you plan to render survey UI yourself, you can skip this package.

  5. Add your platform authentication dependency:

    Add Steamworks.NET to Packages/manifest.json.

    {
    "dependencies": {
    "com.rlabrecque.steamworks.net": "https://github.com/rlabrecque/Steamworks.NET.git?path=/com.rlabrecque.steamworks.net#2025.163.0"
    }
    }

    Unity automatically defines FIRSTLOOK_STEAMWORKS when Steamworks.NET is installed, which enables FirstLookSteamHelper.

The Unity SDK reads configuration from a FirstLookSettings asset.

  1. Create Assets/Resources/FirstLookSettings.asset in the Unity Editor:

    • Assets > Create > FirstLook > Settings
  2. Configure the required fields on the asset:

    • apiUrl: https://api.firstlook.gg
    • clientUrl: https://<game-slug>.firstlook.gg
    • gameSlug: your FirstLook game slug
    • buildVersion: optional build label attached to analytics events
  3. Leave the retry, queue, and logging settings at their defaults unless your project needs different behavior.

FirstLookBootstrap and FirstLookSurveyPresenter can both resolve Resources/FirstLookSettings automatically when it is present.

clientUrl is only required if you plan to open browser-delivered surveys through ActivateSurveyBrowserOverlay(...).

The preferred Unity integration path is host-owned bootstrap. Initialize FirstLook once, authenticate with your platform, and start the session explicitly.

Make sure Steamworks has already been initialized, then authenticate and start the session.

using Pragma.FirstLook;
using UnityEngine;
public sealed class FirstLookStartup : MonoBehaviour
{
[SerializeField] private FirstLookSettings firstLookSettings;
private FirstLookClient _client;
private async void Start()
{
var settings = firstLookSettings != null
? firstLookSettings
: Resources.Load<FirstLookSettings>("FirstLookSettings");
if (settings == null)
{
Debug.LogError("[FirstLookStartup] Missing FirstLookSettings.");
return;
}
_client = FirstLookBootstrap.InitializeWithSettings(settings);
#if FIRSTLOOK_STEAMWORKS
var ticket = FirstLookSteamHelper.GetSessionTicket();
if (string.IsNullOrWhiteSpace(ticket))
{
Debug.LogError("[FirstLookStartup] Steam ticket unavailable. Make sure Steamworks is initialized first.");
return;
}
var result = await _client.AuthenticateAndStartSessionAsync(
FirstLookAuthRequest.Steam(ticket, FirstLookSteamHelper.GetAppId()));
if (!result.Success)
{
Debug.LogError($"[FirstLookStartup] FirstLook startup failed: {result.AuthResult?.Error}");
return;
}
Debug.Log($"[FirstLookStartup] FirstLook ready. Session: {result.SessionId}");
#else
Debug.LogError("[FirstLookStartup] Steamworks.NET is not installed.");
#endif
}
}

Now that the Unity SDK is installed and configured, test the Steam integration locally.

  1. Initialize Steamworks before your FirstLook startup code runs.

    • For example, add a scene object that calls SteamAPI.Init() in Awake() before any call to FirstLookSteamHelper.GetSessionTicket().

  2. Press Play in the Unity Editor or run a development build.
  3. In the Unity Console, confirm a successful startup log from your bootstrap code.

    • e.g. [FirstLookStartup] FirstLook ready. Session: 8c3b8f66-...
  4. If Steam setup is incomplete, expect one of these failure signals instead:

    • [SteamManager] SteamAPI.Init() failed...
    • [FirstLookStartup] Steam ticket unavailable...
    • [FirstLookStartup] FirstLook startup failed: ...

The Unity SDK does not start sessions just by being installed. A session begins when your host calls StartSessionAsync() or uses AuthenticateAndStartSessionAsync(...) successfully.

Once started, the SDK tracks the active session until you end it or the app shuts down. Internally, FirstLookRuntimeDriver attempts to call EndSessionAsync() on application quit as a best-effort graceful shutdown. Players who haven’t created a FirstLook account yet are still tracked — they’ll appear as Unlinked players in your dashboard, with their platform account associated.

Once sessions are being recorded, you’ll see player activity and session duration data on the Analytics page under the Retention tab, as well as on each individual Player Profile.

Beyond session tracking, you can instrument your own gameplay events to capture whatever matters most to your studio — hero selections, match outcomes, store purchases, and more. Use PostCounterEventAsync(...) on FirstLookClient to send a named counter with an integer value:

public async void HandleHeroSelected()
{
if (_client == null || !_client.IsSessionActive)
return;
await _client.PostCounterEventAsync("loadout.hero-a-selected", 1);
}

Event names follow a <category>.<event-type> convention. When you use this pattern, FirstLook will automatically group related events together on the Analytics page and on Player Profiles, making it easy to browse metrics by category.

Choose a category namespace that reflects where the event occurs in your game — for example, match, lobby, menu, store, or in-game. You’re free to define as many categories as you need.

Counter events record that something happened, but sometimes you need to know how long something took. Duration events let you measure elapsed time between two explicit points in your game — a match, a loading screen, time spent in a menu, or any other span you want to track.

Call StartDurationEventAsync(...) when the activity begins and EndDurationEventAsync(...) when it finishes. The SDK handles timing and delivery — you just provide a name.

public async void OnMatchStart()
{
if (_client == null || !_client.IsSessionActive)
return;
await _client.StartDurationEventAsync("match.round");
}
public async void OnMatchEnd()
{
if (_client == null || !_client.IsSessionActive)
return;
await _client.EndDurationEventAsync("match.round");
}

Duration event names follow the same <category>.<event-type> convention as counter events. FirstLook automatically groups them by category prefix on the Analytics page.

Once login and session startup are working, you can trigger in-game surveys from Unity.

  1. Create a survey with game client distribution enabled. See the Creating a Survey.

  2. Set up a trigger for your newly created survey. See the Setting Up Triggers.

  3. If you want the packaged native survey UI, install com.pragma.firstlook.ui and add a FirstLookSurveyPresenter with a FirstLookSurveyCanvas to your scene.

    • FirstLookSurveyPresenter subscribes to OnNewNativeSurveyAvailable, caches the active survey, and can reopen it through TryShowCurrentSurvey().

    • Start from the packaged survey prefabs, skins, and theme assets that ship with the UI package, then duplicate them into your project if you want to customize them.

  4. If you want browser-delivered surveys, subscribe to OnNewBrowserSurveyAvailable in your host code and call ActivateSurveyBrowserOverlay(surveyUuid).

    • The shipped Unity UI package does not auto-open browser-delivered surveys for you.
  5. Trigger the survey from your game:

    await _client.PostSurveyTriggerEventAsync("match.completed");

If you are building fully custom survey UI, you can skip com.pragma.firstlook.ui entirely and subscribe to the core survey events on FirstLookClient directly.