
Unity
The Minit Unity SDK (games.minit.unity) is a UPM package that bridges your C# code to the host-injected window.minit runtime, no JavaScript required.
Quick-Start Steps
Step 1: Create Your Unity Project
Build with the standard Unity workflow (official docs). Two Minit Games-specific requirements:
- Unity 6000.0 (Unity 6) or later: earlier versions produce broken or degraded WebGL builds in the in-app WebViews.
- Portrait orientation: set the default orientation under
Player Settings > Resolution and Presentation, and point your UI Canvas scaler at a portrait reference resolution of 960×1480.
Step 2: Install the Minit Unity SDK
Install via UPM Git URL:
- Open Window → Package Manager.
- Click + → Add package from git URL…
- Paste:
https://github.com/Minit-Games/minit-unity.git?path=/Packages/games.minit.unity - Click Add.
Step 3: Use the API
Call the SDK from any MonoBehaviour:
using UnityEngine;
using MinitGames;
public class GameController : MonoBehaviour
{
private double _score = 0;
private void Start()
{
// Tell the Minit Games platform the game has loaded and is ready to be shown.
// Call this once assets are loaded and the first real frame is ready,
// not necessarily in Start(), which fires before the first rendered frame.
Minit.LoadingDone();
}
// Call once when the game ends.
public void OnGameOver()
{
Minit.ReportResult(_score);
}
}
Minit.LoadingDone(): signals the host the game is ready to be revealed. No precise readiness point? Attach theMinitReadycomponent to any GameObject instead. Details: Game Ready Signal.Minit.ReportResult(score): call exactly once when the game ends. Options and result handling: Reporting Results.Minit.GetConfigValue(string key, string defaultValue = ""): reads a mod config value, e.g.Minit.GetConfigValue("difficulty", "normal"). Values are always strings, so coerce yourself. The key"userData"is reserved and always returnsdefaultValue. Declaring the keys: Config Values.
In the editor and in non-WebGL builds, all three calls log to the Console instead of talking to the host.
Step 4: Select the Minit WebGL Template
The package ships a custom WebGL template named Minit: a viewport-filling, chrome-free canvas. The Default template's progress bar, fullscreen button, and fixed-size canvas are incompatible with the platform.
Minit → Build for Minit (Step 5) selects it automatically. Building manually, select it yourself: Project Settings > Player > WebGL > Resolution and Presentation > WebGL Template > Minit (shown as PROJECT:Minit).
Step 5: Build for WebGL
Use Minit → Build for Minit. It applies compliant Player Settings (Brotli compression, decompression fallback off, Exception support None, IL2CPP with high managed stripping, Wasm linker target, Run in Background on), builds to Build/MinitWebGL/, zips the output with index.html at the archive root as Build/<ProductName>_minit.zip, and warns (non-blocking) on PlayerPrefs usage under Assets/ (PlayerPrefs maps to localStorage, which is forbidden).
Leave WebGL multithreading OFF. A threaded build needs COOP/COEP cross-origin-isolation headers the platform doesn't serve, so it crashes in WKWebView.
Building manually, apply the same settings yourself under File > Build Settings.
Step 6: Upload to Creator Console
Upload the ZIP to the Minit Games creator console: Build/<ProductName>_minit.zip, or your own zip with index.html at the root. It must meet the platform bundle requirements; Build for Minit warns if the output exceeds the limit but still writes the file.
Start from a template
Instead of generating from nothing, clone the official starter template, with structure and SDK wiring already in place:
- minit-template-unity: engine project, SDK wired and simple example game mechanic
Minit Games-Specific Tips
Portrait Mode
The Minit template's canvas already fills the viewport at any portrait aspect ratio. Configure your in-game UI's canvas scaler for portrait (Step 1) and test touch-target sizes on real devices.
Touch Input
The Minit template sets touch-action: none on the canvas so the WebView doesn't intercept touches before Unity sees them. Handling touch itself is standard Unity input work.
Bundle Size
The biggest challenge with Unity: standard WebGL builds are 5–15MB+ before compression, and Games must load instantly (Platform Requirements). Strip aggressively from day one: IL2CPP managed stripping (Build for Minit applies it), sprite atlases, dropping unused assets and packages.
Warning: If your game doesn't need complex physics, advanced rendering, or heavy animation, consider Godot or Defold instead: their web builds are far smaller.
Common Pitfalls
- Persisting via
PlayerPrefs/ browser storage:localStorage,sessionStorage, andIndexedDBare forbidden, andPlayerPrefsis backed bylocalStoragein WebGL. Use the SDK's userData instead: Saving User Data.
Deeper Dives
- Game Ready Signal (Unity):
Minit.LoadingDone()placement, theMinitReadycomponent, and the reveal fallback. - Reporting Results (Unity):
Minit.ReportResult(score, flavorText, delay)with a worked game-over example. - Saving User Data (Unity):
Minit.GetUserData()andReportResult'suserDataparameter.