Flagsmith for Unity

Change the game,not the build.

Flip a flag and the game changes while people are playing it. The panel below runs a real Unity build, so try it. An open-source Unity package for Flagsmith, WebGL included.

Unity WebGL, 5 MB. It plays itself until you tap or press Space.

Flags live, no rebuild

player_skingreen
winter_event
7
coin_value
spike_walls
double_jump
3.2

Events from the game

  • Tap the game to take over. Your first run sends events here.

This is the real package running in WebGL. The page answers for the Flagsmith server, so the panel's flags are yours alone and reach the game on its next 2-second refresh. The tutorial A/B test is real: when Flagsmith Cloud answers, it picks your hint and counts whether you finish your first run, under a random anonymous id. 0 requests answered

Flagsmith has no Unity SDK.

Its FAQ points Unity developers to the .NET SDK. That SDK polls and sends events with System.Threading.Timer, Task.Run and Task.Delay, and Unity's WebGL player has no threads for them to run on. That comes from reading the SDK's source; we have not run it in a WebGL build.

The Flagsmith team's own "Unity SDK" issue, opened in March 2024, was closed as not planned in November 2026. Firebase Remote Config, Statsig, ConfigCat and Unity's Remote Config all support Unity.

Flagsmith for Unity runs on Unity's main thread with UnityWebRequest, caches the last good flags on disk, and speaks Flagsmith's new Experimentation API. Issue #3623 ยท the FAQ

Flag Runner on self-hosted Flagsmith 2.295.2 while server/demo.py edits flags. Speed, the skin, a winter event and the spike walls all change mid-run.

Kill switch: on

Spike walls broken in production? Turn the flag off and every running copy of the game drops them on its next refresh.

The store never sees a patch. This switch drives the playground above too.

spike_walls enabled

Someone edits a flag

In the Flagsmith dashboard, or in Window > Flagsmith inside Unity, run_speed goes from 7 to 11.

Flagsmith dashboard listing Flag Runner's nine flags with their values
  1. Edit
  2. Refresh
  3. Bind
  4. Play

A/B test it on half the players

Call GetExperimentFlag at the moment a player sees the thing under test, and TrackEvent when they succeed. Flagsmith Experimentation does the statistics.

var tut = flagsmith.GetExperimentFlag("tutorial_style");
ShowTutorial(tut?.Value ?? "text");
// later
flagsmith.TrackEvent("first_run_complete");

Exposures are recorded only for enrolled players, and each one is sent once per session. Events are batched under the 2 MiB limit, saved to disk when the app pauses and retried after network errors.

Flagsmith experiment completed: hand is 19.8 percent ahead of text with over 99 percent chance to be best, and hand is rolled out to everyone
Self-hosted Flagsmith after 800 synthetic players from server/simulate.py. The rule (95% chance to be best, 200+ players per arm) was fixed before the second batch of players. It passed, so a coding agent shipped hand to everyone. The lift is simulated on purpose; it says nothing about real players.

Tune it without leaving Unity

Window > Flagsmith lists an environment's flags. Flip a toggle or edit a value, press Save, and the game in Play mode picks it up on its next refresh.

Enter a player ID and the same window changes a flag for that player only: one tester's phone, or the game you are running.

The admin token lives in EditorPrefs on your machine, so it never ends up in the project or in version control.

Editor window guide

The Flagsmith window in the Unity Editor in per-player mode: run_speed and player_skin overridden for one player, each with a Clear button
Window > Flagsmith on self-hosted Flagsmith, with two flags overridden for one player.

It also runs in a released game

Flag Runner was written for this package. Drive Away was not: it is a released Unity game with its own remote values and no server to fetch them from.

In a local build, one 56-line script feeds those values from Flagsmith. Setting season_force to 2 starts the game's Christmas season in the middle of a run.

This is a test build. The version on the stores does not contain Flagsmith.

How it was wired up

Drive Away on self-hosted Flagsmith. season_force changes five seconds into the run, and the run is not restarted.

What has been checked

Tested against self-hosted Flagsmith 2.295.2. The docs list what isn't tested yet.

26 testsEdit mode, one of them against a live self-hosted server
WebGLTested in Chrome: live tuning and experiment events confirmed
No threadsMain thread, UnityWebRequest and Awaitable. No native plugins
OfflineLast good flags cached on disk. Proxy error pages are never cached
Client keys onlyServer-side keys are refused, so no secret ships in a build
AndroidTested on an Android 16 emulator: the game draws and follows flag changes from the server. Not yet on a physical phone

From installto a shipped A/B test

Full guide

Add the package

Package Manager > + > Install package from git URL. Unity 6 or newer.

https://github.com/Harindulk/flagsmith-unity.git?path=/com.flagsmith.unity

Copy your client key

Flagsmith > your environment > SDK keys. Never a ser. key.

Environment Key: your-client-key

Add the component

On a GameObject in your first scene. Paste the key; leave the API URL for Flagsmith Cloud.

Add Component > FlagsmithBehaviour

Add it to your Unity project with one URL.

Paste it into Package Manager > + > Install package from git URL. Newtonsoft JSON comes with it.