Unity SDK · Getting started

Install the Unity SDK

The KalmForge Unity SDK ships as a single C# library that you import into your project, configure once, and boot with one call. Every other system in the manual builds on what's on this page.

Requirements

  • Unity 2022 LTS or Unity 6+.
  • .NET Standard 2.1 / 4.x scripting backend.
  • An internet connection on first launch (the SDK caches everything to disk for offline play afterwards).

Install

  1. Download the latest KalmForge.unitypackage from your dashboard.
  2. In Unity: Assets → Import Package → Custom Package…, select all and import.
  3. The SDK lives under Assets/Plugins/KalmForge/. Do not move the Resources/ subfolder - the runtime loads KalmForgeSettings via Resources.Load.
Tip
Optional packages are auto-detected at runtime: com.unity.mobile.notifications enables Local Notifications, and com.unity.services.authentication auto-binds your player_id to the signed-in Unity Authentication user.

Project Setup Wizard

The SDK ships with an Editor wizard that installs dependencies and configures push notifications for you. Open it from KalmForge → Project Setup Wizard in the Unity menu bar - it also pops up automatically the first time the SDK compiles if anything is missing.

The wizard walks through seven steps:

  1. Overview - green-checks every step the SDK has already detected so you can skip ahead.
  2. Newtonsoft.Json - installs com.unity.nuget.newtonsoft-json via Package Manager (required for SDK download responses).
  3. Firebase - downloads and imports Firebase Cloud Messaging from the KalmForge SDK store, or lets you browse for a local .unitypackage.
  4. Config files - drop google-services.json and GoogleService-Info.plist onto the dropzones; the wizard copies them to Assets/ at the correct location.
  5. Android - patches AndroidManifest.xml with the FCM intent filter, RECEIVE_BOOT_COMPLETED, and the default notification channel meta-data.
  6. iOS - generates Assets/KalmForge/iOS/Entitlements.entitlements and an Xcode post-build processor that wires up Push Notifications + Background Modes on every build.
  7. Finish - adds the HAS_FIREBASE_PUSH_NOTIFICATIONS scripting define and re-verifies everything end-to-end.
Note
You can re-run the wizard any time - completed steps are detected automatically and marked done. Run KalmForge → Check Push Dependencies for a quick status dialog without opening the full wizard.
Heads up
The wizard handles client-side setup only. You still need to upload FCM service-account JSON and APNs .p8 credentials on the dashboard under Project → Notifications → Setup before sends will reach devices - see the Notifications guide.

Configure

Open Window → KalmForge. The first time it runs it creates Assets/Resources/KalmForgeSettings.asset. Paste your Project ID and the API key for each environment you intend to ship to.

Heads up
API keys start with kf_. The SDK rejects anything else with InvalidOperationException at Init(). Never commit production keys to a public repo - use environment-specific keys.

Boot the SDK

GameBoot.csC#
1using KalmForge;
2using UnityEngine;
3
4public class GameBoot : MonoBehaviour {
5 async void Start() {
6 await KalmForgeClient.Init();
7
8 // Optional - boot whichever subsystems your game uses.
9 await System.Threading.Tasks.Task.WhenAll(
10 RemoteConfig.Init(),
11 ABTests.Init(),
12 Localization.Load()
13 );
14
15 Analytics.TrackEvent("game_started");
16 }
17}

KalmForgeClient.Init() is idempotent and returns a cached Task on subsequent calls. It is safe to call from any scene; you do not need a manual scene-bootstrapper.

KalmForgeSettings asset

The settings asset stores your project credentials, the active environment and per-feature opt-out flags. Both the editor window and runtime read from the same file.

KalmForgeSettings - public properties
NameTypeDescription
ProjectIdstringIdentifies your project on the dashboard. Required.
ActiveEnvironmentEnvironmentDevelopment | Production. Selects which API key + endpoint Init() uses.
DevelopmentApiKey / ProductionApiKeystringPer-environment API keys (start with kf_).
DevelopmentEndpoint / ProductionEndpointstringOverride the API base URL. Defaults to https://kalmforge.com.
AnalyticsEnabledboolSet false to disable Analytics at runtime even if your plan includes it.
RemoteConfigEnabled, LocalizationEnabled, …boolOne toggle per subsystem. Useful for opting out per-build (e.g. WebGL without Push).
ActiveApiKeystring (read-only)Resolves to the key for ActiveEnvironment.
ActiveEndpointstring (read-only)Resolves to the endpoint for ActiveEnvironment.
HasAnyKeybool (read-only)True when at least one environment has a key configured.
EditingSettingsAtRuntime.csC#
1var s = KalmForgeSettings.Load();
2s.ActiveEnvironment = KalmForgeSettings.Environment.Production;
3KalmForgeSettings.ClearCache(); // force the next Init() to re-read

Identity

The first time the SDK boots it generates two ids stored in PlayerPrefs:

  • InstallId - per-install GUID, stable across sign-outs.
  • PlayerId - per-project GUID. If Unity Game Services Authentication is installed and signed-in, the SDK picks up its PlayerId instead.

Override the player id when you bring your own account system:

exampleC#
1KalmForgeClient.SetPlayerId(myAccount.UserId);
KalmForgeClient - static API
NameTypeDescription
Versionstring (const)SDK version. Currently "1.0.1".
ProjectIdstringProject id resolved at Init time.
ApiKeystringAPI key resolved at Init time.
EndpointstringBase URL resolved at Init time.
InitializedboolTrue after the first Init() resolves.
PlayerId / InstallIdstringConvenience accessors for KalmForgeIdentity.
Init()TaskBoot the SDK using the active environment from KalmForgeSettings.
EnsureInitialized()voidFire-and-forget Init(); used by other systems internally.
SetPlayerId(string)voidBind a custom player id and persist it for this project.
OnInitializedevent ActionFired once after Init resolves.
OnShutdownevent ActionFired on application quit / pause-to-background.

Lifecycle events

Hook into the client's lifecycle if you want to gate game logic on a successful boot or on shutdown:

exampleC#
1KalmForgeClient.OnInitialized += () => {
2 Debug.Log($"[KF] booted as {KalmForgeClient.PlayerId}");
3};
4
5KalmForgeClient.OnShutdown += () => {
6 // Save anything you need to persist before the process is killed.
7};

Environments

Switch between Development and Production by toggling ActiveEnvironment in the editor window or in code. Each environment carries its own API key, endpoint, and capability set - Remote Config and AB Tests are scoped per-environment server-side.

MemberDescription
KalmForgeSettings.Environment.DevelopmentDefault. Use during local play and QA. Logs are verbose.
KalmForgeSettings.Environment.ProductionUse for store builds. Capability flags are stricter.

Next steps

Back to DocsKalmForge SDK · v1.0.1