Code Generation
The .GENCode() method provides specialized code generation capabilities optimized for programming tasks.
Basic Usage
string code = await "Create a C# class for a player character"
.GENCode()
.ExecuteAsync();Input Types
String Input
string code = await "Unity script that rotates an object"
.GENCode()
.ExecuteAsync();Prompt Input
var prompt = new Prompt("Create a {language} {type} for {purpose}");
string code = await prompt
.GENCode()
.ExecuteAsync();Configuration
Language Selection
Specify the programming language in your prompt:
Code Style
Request specific coding styles:
Complexity Level
Common Use Cases
1. Generate New Code
2. Refactor Existing Code
3. Explain Code
4. Fix Bugs
5. Add Features
6. Convert Between Languages
Unity-Specific Examples
Example 1: MonoBehaviour Component
Example 2: ScriptableObject
Example 3: Editor Script
Example 4: Coroutine
Best Practices
✅ Do
❌ Don't
Provider Support
Provider
Support
Best Models
OpenAI
✅ Full
GPT-4o, GPT-4
Anthropic
✅ Full
Claude 3.5 Sonnet
Google Gemini
✅ Full
Gemini 1.5 Pro
OpenRouter
✅ Full
Various
Groq
✅ Full
Llama 3
Error Handling
Integration Example
Next Steps
Structured Output - Type-safe JSON generation
Chat Completions - General text generation
Responses API - Advanced features
Last updated