QQuickLab
← All articles

· 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 needsEngine
A 3D space where the camera orbits or objects cast shadowsUnity
Rope, cloth or collapsing-pile physicsUnity
Rigged character animationUnity
Hundreds of objects on screen at onceUnity
Post-processing such as bloomUnity
Top-down or side-on 2D where the fun is in the rulesFlame
Lots of menus, lists and other UIFlame

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 it
Pour Parade project layout

Two 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, screenshot

The 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);
});
Get this order wrong and ads silently never show

A few more things bit us along the way.

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_parade

A 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.

Related articles

Seven habits that win more Klondike solitaire games

Dig the tallest hidden column first, empty a column only when a King is ready, and scan the board before you draw. Klondike tips from building Pinegold.

Read →

How we promise “every deal is solvable”: card game solvers and difficulty

Random shuffles include unwinnable deals. How Lantern Cells and Pinegold use a solver to pick deals, measure difficulty and order 120 levels.

Read →

Stuck at FreeCell? Five habits that save your free cells

FreeCell is a game of planning, not luck. The supermove formula, why an empty column beats free cells, and the order of play we learned while building Lantern Cells.

Read →

Seven rules we set while building apps for two-year-olds: Dodam Play and Color Wiggle

Ads, sound, praise, failure and parent locks: the principles behind our upcoming toddler learning app and kids coloring app.

Read →

Amortizing vs equal principal vs interest-only: the interest gap on a 100,000 loan

Same loan, same 4.5% rate, same 30 years, yet total interest ranges from about 67,700 to 135,000 depending on how you repay. How each method works and how to choose.

Read →

What we learned building 42 web tools that run entirely in your browser

Removing modulo bias from random numbers, a metronome that never drifts, line diffs with LCS and Markdown that scripts cannot sneak into: the small techniques behind QuickLab’s free tools.

Read →

The arithmetic is right—so why is the puzzle wrong? A Math Lattice guide

Worked examples for crossing equations, practical solving tips, and ways to play with children and older adults—without overstating school or brain-health benefits.

Read →

Stuck on a line puzzle? Leave a route for the other colors

Practical Lumen Lanes tips for tight passages and connection order, ways to play with family, and what brain-health research does—and does not—tell us.

Read →

Studying English words with Word Sprout: a tour of every feature, with screenshots

From snapping a school word list to flash cards, multiple choice, matching pairs, spelling, dictation, tests and an exam date. A screen-by-screen look at Word Sprout’s learning features and why each one is there.

Read →

Turning Blender into a game-art script with Python

How Word Sprout’s flower pots, mascot, 113 flower cards and 3D garden are made with Blender Python scripts: building characters from basic shapes, Freestyle outlines, and exporting meshes for Unity.

Read →

Stuck on a color sort puzzle? Start by saving the empty bottle

Why pour-and-sort puzzles suddenly jam up in later levels, and how to get through them with fewer moves, using Pour Parade as the example.

Read →

We put four games on Google Play

The four games MandooHai Studio has released on Google Play so far, and a few things we try to stick to when making them.

Read →

A week before the word test, 15 minutes a day is enough

Instead of cramming the night before, spend 15 minutes a day for a week. A day-by-day plan for a child’s English word test.

Read →

Spaced repetition and the Leitner box: for kids who forget yesterday’s words

Why words your child knew last night are gone by morning, and how to try the Leitner system, five boxes that decide when to review, at home.

Read →