direct-entity-manager-structural-changes

Guide direct EntityManager batch operations for Unity DOTS structural changes.

6|Updated Apr 2, 2026
One-click install
npx skills add https://github.com/dyCuong03/unity-agent-team --skill direct-entity-manager-structural-changes
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: direct-entity-manager-structural-changes
Source: https://github.com/dyCuong03/unity-agent-team/tree/main/.claude/skills/unity-dots/direct-entity-manager-structural-changes
Command: npx skills add https://github.com/dyCuong03/unity-agent-team --skill direct-entity-manager-structural-changes

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It prevents unsafe or expensive Unity DOTS structural changes by guiding when and how to use EntityManager directly for one-shot, batch operations.

Core Features & Use Cases

  • Main-thread batch structural changes: Use EntityManager outside active query iteration to initialize or respawn large sets efficiently (e.g., mass Instantiate, Add/Remove components, Destroy by query).
  • Safety-first patterns: Avoid structural changes inside SystemAPI.Query foreach and avoid accessing EntityManager from scheduled jobs.
  • Performance-oriented approach: Prefer batch overloads and one-shot system disabling to reduce archetype operations and eliminate per-frame duplication.

Quick Start

In a one-shot ISystem OnUpdate, disable the system with state.Enabled = false before work, then use state.EntityManager.Instantiate(prefab, count, Allocator.Temp) and apply component/buffer changes via batch or query-based APIs outside any query foreach loop.

Frequently Asked Questions about direct-entity-manager-structural-changes

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I make safe structural changes with EntityManager in Unity DOTS?

Safe EntityManager structural changes in Unity DOTS require performing one-shot batch operations on the main thread outside of SystemAPI.Query foreach loops and scheduled jobs. Use batch overloads and query-based Add, Remove, or Destroy APIs to ensure correctness and avoid archetype fragmentation.

When should I use direct EntityManager batch operations instead of per-frame structural changes?

Direct EntityManager batch operations are appropriate for one-shot initialization, infrequent config-driven respawns, and mass batch structural changes on the main thread. Avoid using this approach for per-frame hot paths to prevent expensive archetype operations and performance degradation.

Why does accessing EntityManager inside SystemAPI.Query cause issues in Unity ECS?

Accessing EntityManager inside SystemAPI.Query causes issues because iterating active queries while making structural changes invalidates entity references and corrupts archetype chunks. Safety patterns dictate using batch overloads and query-based APIs outside the foreach loop to maintain data integrity.

Can I use EntityManager to mass Instantiate prefabs on the main thread in Unity DOTS?

Yes, you can mass Instantiate prefabs on the main thread using state.EntityManager.Instantiate(prefab, count, Allocator.Temp). Disable the one-shot ISystem with state.Enabled = false before executing work, then apply component or buffer changes via batch or query-based APIs.

What are the limitations of using direct EntityManager for structural changes in Unity ECS?

Limitations include the inability to access EntityManager from scheduled jobs and the prohibition against making structural changes inside SystemAPI.Query foreach loops. Using direct EntityManager operations on per-frame hot paths causes expensive archetype operations and should be avoided for regular updates.

Does direct EntityManager structural changes work with Unity DOTS burst jobs?

Direct EntityManager structural changes do not work with scheduled burst jobs. Accessing EntityManager from jobs breaks safety patterns; structural changes must be executed as one-shot batch operations on the main thread using query-based Add, Remove, and Destroy overloads.