Overview
KalmForge.InGameMessages is a static class that talks to a hidden InGameMessagesController MonoBehaviour spawned on first show. There are two delivery modes:
- Auto-queue - messages with no
trigger_keyare fetched and queued bySyncAsync(). - Trigger-keyed - messages with a
trigger_keyonly render when you callTryShow(key).
The server filters by language, platform, segment, max-views and cooldown, so the same player won't see the same message too often.
Quick start
1using KalmForge;23async void Start() {4 await KalmForgeClient.Init();56 InGameMessages.SetButtonHandler((messageId, action) => {7 if (action.Type == "reward") GrantReward(action.Value);8 });910 await InGameMessages.SyncAsync(); // queue all auto-show messages11 await InGameMessages.TryShow("first_run"); // show the "first_run" trigger if eligible12}Auto-queue messages
SyncAsync() requests every message without a trigger key and enqueues them. The controller drains the queue one at a time - each dismiss starts the next one. Safe to call repeatedly; the server de-duplicates per max_views_per_player and cooldown_seconds.
Trigger-keyed messages
1bool shown = await InGameMessages.TryShow("level_failed_3x");2// false → no eligible message (already shown / segment mismatch / capability off)Button actions
Each button on a message has an action Type + Value. The SDK auto-handles url and deep_link via Application.OpenURL; everything else is forwarded to your handler:
| Name | Type | Description |
|---|---|---|
| "close" | string | Just dismiss the message. (Default for auto-synthesised OK.) |
| "url" | string | Value is a URL. SDK calls Application.OpenURL(value). |
| "deep_link" | string | Value is a deep link. Same handling as "url". |
| "reward" | string | Custom - your handler grants the reward. |
| "dismiss_forever" | string | Custom - your handler should mark this message as never-show-again. |
Settings asset
Default theme, render backend, font source and panel scale are configured under Window → KalmForge → In-Game Messages (creates Resources/InGameMessagesSettings.asset). Pick:
- UIToolkit (default) - uses your project's
PanelSettings. - UGUI - Canvas + Image + Text. Supports legacy fonts and (with TMP installed)
TMP_Text. - IMGUI - fallback for editor / debug overlays.
InGameMessages.AlwaysOnTop = true (default) guarantees the popup paints above every other Unity surface, including Screen-Space-Overlay uGUI canvases, by spawning a high-depth camera and temporarily switching competing canvases to ScreenSpace-Camera.Events
| Name | Type | Description |
|---|---|---|
| OnMessageShown | event Action<string> | Fires with the message id when it becomes visible. |
| OnMessageDismissed | event Action<string> | Fires with the message id when it dismisses. |
API reference
| Name | Type | Description |
|---|---|---|
| SyncAsync() | Task | Fetch + queue all auto-show messages. |
| TryShow(triggerKey) | Task<bool> | Show the next eligible trigger-keyed message. |
| SetButtonHandler(Action<id, ButtonAction>) | void | Receive non-url/deep_link button actions. |
| ReportAsync(messageId, action) | Task | Manually report a custom interaction (e.g. "shown", "clicked"). |
| AlwaysOnTop | bool | Default true. See callout above. |
REST endpoint
1# Fetch eligible messages2GET /api/public/sdk/in-game-messages3 ?player_id=...&install_id=...&lang=en&platform=ios4 [&trigger=level_failed_3x]5Headers: X-API-Key: kf_xxx_yyy67# Report an interaction8POST /api/public/sdk/in-game-messages9{ "message_id": "...", "player_id": "...", "install_id": "...", "action": "shown" }