· QuickLab
Making mobile puzzle games in Unity, with no scenes or prefabs
How we build Pour Parade, Math Lattice and Munchling Meadow in Unity: how we pick an engine, a project built entirely in code, tests that run without Unity, and where AdMob and Hindi text tripped us up.
The puzzle games we publish on Google Play as MandooHai Studio are made with Unity 6 LTS. They don’t look much like a typical Unity project, though. Instead of laying out scenes in the editor and dragging prefabs around, we build almost everything in C#. This is a write-up of why, and how it works in practice.
We pick the engine per game
We didn’t start out Unity-only. For each game we choose between Flame, a 2D engine built on Flutter, and Unity. The deciding factor is what the game needs, not taste.
| What the game needs | Engine |
|---|---|
| A 3D space where the camera orbits or objects cast shadows | Unity |
| Rope, cloth or collapsing-pile physics | Unity |
| Rigged character animation | Unity |
| Hundreds of objects on screen at once | Unity |
| Post-processing such as bloom | Unity |
| Top-down or side-on 2D where the fun is in the rules | Flame |
| Lots of menus, lists and other UI | Flame |
When it was a toss-up, Flame was the default. The Flutter side already had a script that builds, installs, launches and screenshots in one go, plus a shared package for ads, saving and leaderboards. Unity needed all of that built from scratch.
Once the Unity tooling existed, though, things changed. What used to be a 2D bottle-sorting game was rebuilt in 3D as Pour Parade. Math Lattice is a flat grid of numbers with nothing 3D about it, yet it’s in Unity too, so it could reuse the tokens, ads, localization, UI kit and build scripts we already had. Its design doc honestly notes that, engine-wise, Flame would have been enough.
Scenes, prefabs and images, all in code
The Pour Parade project has almost no asset files. The bottle and liquid meshes are generated in code, glass, liquid, wood, background and shadows are drawn by hand-written shaders, and the sound effects are synthesized in code too. The UI is assembled from uGUI in code, and even the scene file is created at build time. The folders look like this.
Assets/
├── Scripts/
│ ├── GameConfig.cs # every tuning constant lives here
│ ├── Puzzle/ # pure C# rules and level generation (no UnityEngine)
│ ├── Core/ # play tokens, ads, storage, settings, sound
│ ├── View/ # procedural meshes (bottles, liquid, stream, shelf), camera
│ ├── UI/ # uGUI built in code (no prefabs)
│ ├── L10n/ # seven languages
│ └── App/ # bootstrap and game flow
├── Shaders/ # glass, liquid, wood, background, shadow
└── Editor/AndroidBuild.cs # command-line build entry point
Tests~/ # ends in '~', so Unity ignores itTwo things make this worth it. No binaries pile up in the repository, and every change reads as a diff. Scene and prefab files may be text, but they’re hard for people to read; code shows exactly what changed. Balance and animation numbers all live in one file, GameConfig.cs, so there’s never a hunt for the right knob.
The cost is that a layout you could drag into place in a minute takes longer to write. For puzzle games with simple screens, that was a price worth paying.
Testing without opening Unity
A Unity Android build takes more than ten minutes. We couldn’t wait that long every time a rule changed, so the rules and level generation live in Puzzle/ as pure C# that never touches UnityEngine.
The tests sit in Tests~. Unity skips any folder whose name ends in ~, so we can run ordinary C# tests there with dotnet. We also keep a fake UnityEngine (a stub) in there and check that every script compiles against it. The whole thing finishes in seconds.
tools/test_unity_logic.sh pour_parade # seconds: rules, difficulty, translations, compile
tools/test_unity_logic.sh pour_parade --report # plus a per-level difficulty table
tools/run_unity_android.sh pour_parade # 10+ minutes: real build, install, screenshotThe fast check always goes first. Change the logic, run the tests, and only when they pass do a real build and look at the emulator. The build script runs Unity in batch mode to produce an APK, then installs, launches and screenshots it with adb. Development builds can even jump straight to a level and language with adb shell am start ... -e level 61 -e locale ja.
Measure the difficulty, then lock it in with tests
In a puzzle game the difficulty curve is nearly everything, and tuning it by playing a few rounds yourself is easy to get wrong. So alongside each level generator we build a simulated player and measure.
Munchling Meadow is a good example. Early on the boards were just pictures, and a simulated player tapping completely at random won all 40 levels. Most colors were big blobs touching the outside, so order didn’t matter. We added checkered leaves to fill the gaps in each picture so that order would matter, then measured the win rate of a player who half the time picks a color that’s already exposed and half the time taps anything, 400 games per level, and tuned each level to a target: 100% for levels 1 and 2, about 20% by level 40.
Math Lattice’s first curve was far too gentle: every level up to 8 was three equations with two blanks. We redrew it and locked two rules in with tests: the number of blanks never drops from one level to the next, and the same count never repeats for more than four levels. If a later tweak breaks either, the tests catch it first.
Using the level number as the random seed comes from the same thinking. A level is the same board on every device, so “level 61 looks wrong” is enough to reproduce it exactly. We wrote our own random number generator (xorshift128) for this.
When AdMob quietly does nothing
Ads come from the Google Mobile Ads Unity plugin, and this is where we got stuck the longest: no errors, just no ads. The cause was initialization order.
// 1. Receive SDK callbacks on Unity's main thread
// (calling Unity APIs from a Java thread throws)
MobileAds.RaiseAdEventsOnUnityMainThread = true;
// 2. Before the consent (UMP) check, create the executor on the main thread;
// without it the consent callback never runs
MobileAdsEventExecutor.Initialize();
// ... UMP consent check ...
// 3. Set the request configuration inside the init callback
MobileAds.Initialize(status => {
MobileAds.SetRequestConfiguration(config);
});A few more things bit us along the way.
- With a real app ID, you need a consent message published under Privacy & messaging in the AdMob console. Without one, the consent check fails and ad requests are blocked entirely.
- The very first build of a new project shipped a manifest without the AdMob app ID and crashed on launch. Our build script now checks the manifest after building and bakes it again if the ID is missing.
- Development builds always use Google’s test IDs, even when real IDs are present. Seeing or tapping your own ads during development counts as invalid traffic and can get the account suspended. The real IDs live only in a
Secrets.jsonthat never goes into git.
The ad setup itself is the same in every game: a daily number of free plays, and once they’re gone, a rewarded ad for more plays only if you choose to watch one. No full-screen ads between levels.
Seven languages, and Hindi
Every game ships in seven languages. The source translations are ARB files, same as on the Flutter side, and a script (sync_locales.py) generates the JSON Unity reads. The JSON is an output, so we never edit it by hand.
Hindi was the surprise. Unity’s built-in Text draws characters one at a time without shaping them, so Devanagari vowel signs landed in the wrong place and conjuncts fell apart. TextMeshPro had the same problem. In the end we draw only the strings that contain Devanagari with Android’s own text engine (StaticLayout) and lay the result over the original as a texture. The original Text stays in place, transparent, so layout and text-update code didn’t have to change.
Then button labels started wrapping onto two lines. Unity measures width using the unshaped characters, which comes out narrower than the shaped text actually is. We finished it off by not wrapping a one-line label when it overflows by 25% or less.
Fingers wobble more than you think
In Math Lattice, numbers kept popping back out when players tapped them. A slightly shaky tap was being read as a drag. Unity’s default threshold of 10px is less than a millimeter on a high-density phone. Switching to about 2.5mm based on the device’s dpi made the problem go away. A surprising number of values need to be thought of in real-world length, not screen pixels.
Building and shipping
The Play Store AAB is one script away as well. You create an upload key once, keep the key files out of git and back them up separately, and always bump the version code above the last upload.
tools/build_unity_aab.sh --init-signing # once: create the upload key
UNITY_ANDROID_VERSION_CODE=2 UNITY_ANDROID_VERSION_NAME=0.1.1 \
tools/build_unity_aab.sh pour_paradeA brand-new personal developer account can’t go straight to production. At least 12 testers need to stay opted in to a closed test for 14 days in a row before you can apply. If you plan to ship several games, build that time into the schedule.
Still to do
We haven’t properly verified the iOS builds yet. And this approach probably works because these are puzzle games with simple screens; a game full of characters and animation would need the editor a lot more. We’ll write that up when we get there. The art side of things is in Turning Blender into a game-art script.