API Example
This sample demonstrates driving KitForge AI programmatically using strictly
the public C# API surface in the DecnetGames.KitForgeAI namespace
(Package Manager sample API Example, path Samples~/APIExample).
What the driver does
The APIExampleDriver script executes an automated end-to-end workflow:
- Profile Kit — scans a modular kit folder (
KitForge.ProfileKit) and detects piece roles and grid dimensions. - Load Plan — reads a structure plan from a JSON file
(
KitForge.LoadPlan). - Assemble Structure — places kit prefabs into the active scene
(
KitForge.Build) with deterministic seed ordering. - Audit Census — reads the
BuildReportto verify piece counts, skipped pieces, and placement integrity.
Usage
To execute the example in the Unity Editor:
using DecnetGames.KitForgeAI.Samples;
// Run with default sample paths:
bool success = APIExampleDriver.RunExample();
// Or run with custom kit and plan paths:
bool customSuccess = APIExampleDriver.RunExample(
"Assets/MyModularKit",
"Assets/Plans/CastleOutpost.json"
);
All methods return strongly-typed result objects (ProfileResult,
PlanResult, BuildResult) and never throw exceptions across the public
boundary.
Next: the full API Reference and the Agent Guide for driving KitForge AI from an AI coding agent.