C# Object Generation
Object Generation lets you turn natural language prompts into strongly-typed Unity C# objects by guiding the AI to return JSON that matches your class definition.
It's perfect for generating game data like:
📦 Items
🎮 Quests
🗨️ NPC Dialogue Trees
📋 Skill Definitions
🧠 AI Configuration Profiles
✅ How It Works
Define a C# class with special attributes
Call
.GENObject<T>()
with a descriptive promptAI returns JSON, which is parsed into a
T
object usingJsonConvert
🔒 Schema guidance ensures the AI produces valid JSON matching your structure.
🚨 Required Annotations
OpenAI
[OpenAIJsonSchemaResponse(...)]
(on the class)
Others (e.g. Gemini)
[JsonSchema(...)]
(on each property)
These attributes are mandatory. Without them, the task will fail to register the schema.
🎮 Example: Generate an RPG Item
✅ Unity Usage
🧪 Example Output from AI
🎮 Example: Generate a Simple Quest
🧠 Tips for Better Accuracy
Use Strict = true
Ensures output matches your schema exactly
Provide clear, focused prompts
e.g., "Generate a level 5 healing potion item"
Use [JsonSchema]
attributes
Describes intent to both AI and schema validator
Catch errors with try/catch
Handle malformed JSON safely in production
🧩 JSON Schema Attributes Cheat Sheet
Name
JSON field name
Description
AI guidance
Required
Ensures field presence
Enum
Limits possible values
Minimum
, Maximum
For numbers
MinItems
, MaxItems
For arrays
AdditionalProperties
Disable extra fields
Last updated