Login Register
Working Efficiently: Batch Operations

Using unity.batch_operation for Multiple Scripts

Estimated reading: 0 minutes 7 views

The unity.batch_operation command freezes recompilation, allows multiple file creations, then triggers one recompile. This dramatically reduces wait time when generating many scripts at once, transforming what would be minutes of waiting into seconds of efficient execution.

The problem it solves:

Normally, creating a script triggers Unity recompilation. If you create 10 scripts sequentially, Unity recompiles 10 times. Each recompilation takes 5-15 seconds depending on project size and complexity. Total time: 50-150 seconds of waiting, during which you can’t do anything productive.

This compounds quickly. Creating 50 scripts for a complex system? That’s 4-12 minutes of pure waiting time. Creating 100 scripts for a large refactoring? 8-25 minutes. The time adds up fast, and it’s all wasted time where you’re just staring at a progress bar.

The batch solution:

Freeze recompilation, create all 10 scripts (or 50, or 100), unfreeze and trigger one recompile. Total time: 5-15 seconds regardless of how many files you created. The time savings are massive:

  • 10 scripts: 50-150 seconds → 5-15 seconds (10x faster)
  • 50 scripts: 250-750 seconds → 5-15 seconds (50x faster)
  • 100 scripts: 500-1500 seconds → 5-15 seconds (100x faster)

Available actions:

The unity.batch_operation command supports four actions:

  • action="begin" — Freezes recompilation. Unity stops watching for file changes. You can create as many files as you want without triggering recompilation.
  • action="execute" — Unfreezes and triggers one recompile. Unity processes all file changes at once and recompiles the entire project.
  • action="abort" — Unfreezes without recompiling. Use this if you decide to cancel the batch operation or if something goes wrong.
  • action="status" — Checks if batch mode is active. Returns true if recompilation is frozen, false otherwise.

Basic workflow:

Here’s the simplest batch operation workflow:

  1. Vex calls unity.batch_operation action="begin" — Recompilation freezes
  2. Vex creates 10 script files using file.create — Each file.create succeeds instantly without triggering recompilation
  3. Vex calls unity.batch_operation action="execute" — Recompilation unfreezes and Unity processes all 10 files at once
  4. Unity recompiles once — One recompilation cycle handles all 10 files

Result: 10 files = 1 recompile. Time saved: 85-135 seconds.

When Vex uses batch mode:

Vex automatically uses batch mode when:

  • workspace.plan includes multiple script creation tasks in sequence
  • You explicitly ask Vex to create many files at once
  • Vex detects a pattern of repetitive file creation (e.g., “create 20 enemy types”)

You don’t need to tell Vex to use batch mode. Vex knows when it’s appropriate and uses it automatically.

Safety considerations:

  • Batch mode only affects recompilation, not file operations. Files are still created with normal safety checks (dry-run mode, protected paths, etc.)
  • If Unity crashes during batch mode, recompilation automatically unfreezes on restart
  • You can manually abort batch mode from the Dashboard if needed
Share this Doc

Using unity.batch_operation for Multiple Scripts

Or copy link

CONTENTS
Antimanual

Ask our AI support assistant your questions about our platform, features, and services.

You are offline
Chatbot Avatar
What can I help you with?