AIDevKit - AI Suite for Unity
API ReferencesDiscordGlitch9
  • Introduction
    • AI Dev Kit 3.7.0
    • Troubleshooting
    • FAQ
    • Update Logs
  • Provider Setup
    • API Key Setup
    • OpenAI
    • Google Gemini
    • ElevenLabs
    • Ollama
    • OpenRouter
  • Editor Tools
    • Introduction
    • Editor Chat
    • Model Library
    • Voice Library
  • GEN Tasks
    • Overview
    • Prefixes
    • Response
    • Chat
    • Image
    • Video
    • SoundFX
    • Speech
    • Transcript
    • Voice Change
    • Audio Isolation
    • Sequence
  • Advanced API (Pro)
    • Assistants
      • How it works
      • Creating custom functions
      • Creating assistants API
    • Realtime
  • 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 Dev Kit 1.0
      • Preperation
      • 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
    • AI Dev Kit 2.0
      • Event Handlers
      • 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 Unity Component Generator
  • Using the Unity Component Generator
  • Best Practices
  1. Legacy Documents
  2. AI Dev Kit 1.0
  3. Code Generators

Unity Component Generator

PreviousC# Script GeneratorNextAI Dev Kit 2.0

The Unity Component Generator is an innovative tool that simplifies the process of creating MonoBehaviour scripts tailored for specific components within Unity. Leveraging OpenAI's advanced models, this tool generates scripts based on descriptive prompts provided by developers, directly integrating them as components on GameObjects in the Unity Editor.

Accessing the Unity Component Generator

The Unity Component Generator integrates seamlessly into the Unity Editor, enhancing the development workflow with AI-powered script generation:

  1. Select a GameObject in your scene that you wish to add a new component to.

  2. In the Inspector window, locate the 'Generate Component' button situated directly under the traditional 'Add Component' button.

Using the Unity Component Generator

Step 1: Describing the Desired Component

After clicking 'Generate Component', a window will appear prompting you to describe the functionality of the component you want to generate. Your description should be as detailed as possible to guide the AI in generating a script that matches your requirements. For example:

  • "Create a script that makes an object rotate continuously."

  • "Generate a health system component with methods for taking damage and healing."

Step 2: Reviewing Generated Code

Once you've submitted your prompt, the tool processes your request and presents the generated script code for review. This is where you can assess the code's suitability for your project and ensure it aligns with your intended functionality.

Step 3: Confirming and Attaching the Script

  • Confirmation: If the generated script meets your expectations, confirm the generation. This will automatically create a new C# script file in your project and attach it as a component to the selected GameObject.

  • Revision: If the script requires adjustments or does not meet your needs, you can modify the prompt and regenerate the script.

Best Practices

  • Clear and Concise Prompts: The accuracy of the generated script heavily depends on the clarity and detail of your prompts. Clearly state the intended functionality and any specific requirements.

  • Iterative Generation: Don't hesitate to regenerate the script with adjusted prompts for better outcomes.

  • Script Review: Always review the generated script thoroughly. Even though the script is generated based on your prompt, it may require minor tweaks or optimizations to perfectly fit your project's architecture and coding standards.