AI Dev Kit
API ReferencesDiscordGlitch9
  • Introduction
    • AI DevKit 3.7.0
    • Troubleshooting
    • FAQ
    • Update Logs
  • Provider Setup
    • OpenAI
    • Google Gemini
    • ElevenLabs
    • Ollama
    • OpenRouter
  • Editor Tools
    • Introduction
    • Editor Chat
    • Model Library
    • Voice Library
  • GEN Tasks
    • Introduction - Prefixes
    • Text/Content Generation
      • Structured Outputs (JSON Mode)
    • Chat Session
    • Image Generation
    • Video Generation
    • Sound FX Generation
    • Text to Speech (TTS)
    • Speech to Text (STT)
    • Voice Change
    • Audio Isolation
  • Advanced APIs (Pro)
    • Assistants API
      • How it works
      • Creating custom functions
      • Creating assistants API
    • Realtime API
  • Legacy API
    • OpenAI
      • 💬Chat completions
      • 🖼️Image operations
      • 🗣️Text to speech
      • 🎙️Speech to text
        • Recording real-time in Unity
      • 💾Files
      • 🔎Embeddings
      • 🛡️Moderations
      • ⚙️Fine-tuning
    • Google Gemini
      • 📝System instructions
      • 💬Text generation
      • ⚙️Fine-tuning
      • ▶️Fucntion calling
      • 🔎Embeddings
      • 🛡️Safety
      • 💻Code execution
  • Legacy Documents
    • AI DevKit 1.0 - 2.0
      • AI DevKit 2.0
      • AI DevKit 1.0
      • Preperation
      • Event Handlers
      • Scriptable Toolkits
        • Chat Streamer
        • Image Generator
        • Voice Transcriber
        • Voice Generator
      • Editor Tools
      • Troubleshooting (Legacy)
        • ❗Build Error: The name 'UnityMenu' does not exist in the current context
        • ❗The type or namespace name 'AndroidJavaObject' could not be found
        • ❗The type or namaspace name 'Plastic' does not exist
        • ❗Build Error: The name 'Asset Database' does not exist in the current context
        • ❗'ModelData.Create(Provider, string, UnixTime?, string)': not all code paths return a value
      • Code Generators
        • C# Script Generator
        • Unity Component Generator
      • Generation Menu
      • Editor Chat
      • Editor Vision (TTI, ITI)
      • Editor Speech (TTS)
      • Management Tools
        • Prompt History Viewer
        • AI Model Manager
        • TTS Voice Manager
        • OpenAI File Manager
        • OpenAI Assistant Manager
        • ElevenLabs Voice Library
Powered by GitBook
On this page
  • Accessing the C# Script Generator
  • Using the C# Script Generator
  • Best Practices
  1. Legacy Documents
  2. AI DevKit 1.0 - 2.0
  3. Code Generators

C# Script Generator

PreviousCode GeneratorsNextUnity Component Generator

C# Script Generator streamlines the creation of C# scripts for Unity developers. By leveraging OpenAI's GPT models, it generates scripts based on natural language prompts, facilitating rapid development of functionalities that would typically require more time to code manually.

Accessing the C# Script Generator

To access the C# Script Generator:

  1. Navigate to the Project window within the Unity Editor.

  2. Right-click on the desired directory where you wish to generate the new script.

  3. Find the Generate C# Script with GPT button located directly under the Create button at the top of the context menu.

Using the C# Script Generator

Step 1: Inputting Your Prompt

After opening the C# Script Generator window, you'll be prompted to describe the script you want to generate. This description should be as detailed as possible to ensure the generated script meets your needs. Examples of prompts include:

  • "Implement a generic singleton pattern for game managers."

  • "Create a player movement script using Rigidbody for a 3D platformer."

Step 2: Configuring Script Options

  • Namespace: Optionally, specify the namespace for your script. This helps in organizing your code and preventing naming conflicts.

  • Model Selection: Choose between available GPT models for script generation. Different models may offer varying levels of creativity and accuracy.

Step 3: Generating the Script

Once you have input your prompt and configured the script options, click the "Generate" button. The tool will communicate with OpenAI's API and generate a C# script based on your description.

Step 4: Reviewing and Confirming

  • Review: The generated script will be displayed for your review. You can read through the code to ensure it aligns with your project requirements.

  • Confirmation: If the script meets your expectations, confirm the generation to add the script to your project. If not, you can modify the prompt and regenerate the script.

Best Practices

  • Detailed Prompts: Provide detailed and specific prompts to improve the relevance and accuracy of the generated scripts.

  • Prompt Examples: Use the "Show me some examples" feature for inspiration or to better understand how to formulate effective prompts.

  • Review Generated Code: Always review the generated code for accuracy, efficiency, and adherence to best practices before integrating it into your project.