ecs-dots · git:20261010.ceeff3d · 2026-10-10 · sha256 54b7ceb9b5cea3be

ecs-dots git:20261010.ceeff3dB

Immutable. This exact content never changes and is served at /api/v1/blob/54b7ceb9b5cea3be.

No tool to install first
claude plugin marketplace add https://markdownregistry.com/mp/a/art_mlwklb67zokci4ca/54b7ceb9b5cea3beafb34f2831b6946c4de07b92dbf1e0308a0224ddf0b856c9.json

Then /plugin install ecs-dots@markdownregistry-mlwklb67zokci4ca in Claude Code. It installs this exact version, the one graded B here, pinned to the commit it was graded at, and leaves it there.

---
title: ECS and DOTS
description: Use when the user works with DOTS, ECS, Entities, ISystem or SystemBase, IComponentData, Bakers, SubScenes, the Job System, or Burst, or needs to simulate thousands of objects. Covers entity queries, baking, entity command buffers, jobs, and Burst constraints.
globs: ["**/*.cs"]
standards-version: 1.10.0
---

# ECS and DOTS

## Status in 2026

The Data-Oriented Technology Stack (DOTS) is now a core part of the Unity engine, not an experimental package. In Unity 6.4, Entities, Collections, Mathematics, and Entities Graphics became core packages: they ship with the Editor and their version matches it (Entities 6.4 in Unity 6.4). On Unity 6.0 to 6.3, install the Entities 1.x package. ECS is production-ready for:

- Massive entity counts (thousands to millions)
- High-performance simulations and physics
- Large-scale multiplayer (Netcode for Entities)
- Procedural world generation

## Core Concepts

### Entity

A lightweight identifier (integer) that represents a game object in ECS. Entities have no behavior or data themselves - they are just IDs that components are attached to.

### IComponentData

Data containers with no behavior. Must be structs:

```csharp
public struct MoveSpeed : IComponentData
{
    public float Value;
}

public struct Health : IComponentData
{
    public int Current;
    public int Max;
}
```

### Systems

Logic that processes entities with specific component combinations.

#### ISystem (Unmanaged - Preferred)

```csharp
[BurstCompile]
public partial struct MoveSystem : ISystem
{
    [BurstCompile]
    public void OnUpdate(ref SystemState state)
    {
        float dt = SystemAPI.Time.DeltaTime;

        foreach (var (transform, speed) in
            SystemAPI.Query<RefRW<LocalTransform>, RefRO<MoveSpeed>>())
        {
            transform.ValueRW.Position += new float3(0, 0, speed.ValueRO.Value * dt);
        }
    }
}
```

#### SystemAPI.Query (Main Thread)

Use for simple iteration on the main thread. Structural changes (creating or destroying entities, adding or removing components) are not allowed while a query is being iterated, so record them in an `EntityCommandBuffer` and let a command buffer system play them back:

```csharp
[BurstCompile]
public partial struct DeathSystem : ISystem
{
    public void OnCreate(ref SystemState state)
    {
        state.RequireForUpdate<EndSimulationEntityCommandBufferSystem.Singleton>();
    }

    [BurstCompile]
    public void OnUpdate(ref SystemState state)
    {
        var ecb = SystemAPI.GetSingleton<EndSimulationEntityCommandBufferSystem.Singleton>()
            .CreateCommandBuffer(state.WorldUnmanaged);

        foreach (var (health, entity) in SystemAPI.Query<RefRO<Health>>().WithEntityAccess())
        {
            if (health.ValueRO.Current <= 0)
            {
                ecb.DestroyEntity(entity);
            }
        }
    }
}
```

#### IJobEntity (Parallel - High Performance)

Use for parallel processing across multiple threads:

```csharp
[BurstCompile]
public partial struct DamageJob : IJobEntity
{
    public int DamageAmount;

    public void Execute(ref Health health)
    {
        health.Current -= DamageAmount;
    }
}

// Schedule in system:
new DamageJob { DamageAmount = 10 }.ScheduleParallel();
```

## Deprecated ECS Patterns

Entities 1.3 marked these obsolete; they still work in 1.x but will be removed in a future major release:

| Deprecated | Replacement |
|-----------|-------------|
| `Entities.ForEach` | `SystemAPI.Query` or `IJobEntity` |
| `IAspect` | Components, `ComponentLookup`, and `EntityQuery` directly |

`SystemBase` is not deprecated. Prefer `ISystem` for new code because it is unmanaged and can be Burst-compiled end to end; use `SystemBase` when a system needs managed data (managed components, class references, or main-thread UnityEngine APIs).

## Jobs System

The C# Job System provides safe multithreaded code:

```csharp
[BurstCompile]
public struct DistanceCalculationJob : IJobParallelFor
{
    [ReadOnly] public NativeArray<float3> Positions;
    public NativeArray<float> Distances;
    public float3 Target;

    public void Execute(int index)
    {
        Distances[index] = math.distance(Positions[index], Target);
    }
}
```

Use `NativeArray<T>`, `NativeList<T>`, `NativeHashMap<K,V>` for job-safe collections.

## Burst Compiler

Burst compiles C# Jobs into highly optimized native code:

- 10x to 100x performance improvement over standard C#
- SIMD vectorization automatic
- Add `[BurstCompile]` to jobs and ISystem structs
- Restrictions: no managed types, no reference types, no try/catch

Use `Unity.Mathematics` types (`float3`, `quaternion`, `math.*`) for best Burst optimization.

## Baking (Authoring to Runtime)

Convert GameObjects to entities at build time:

```csharp
public class MoveSpeedAuthoring : MonoBehaviour
{
    public float Speed;

    public class Baker : Baker<MoveSpeedAuthoring>
    {
        public override void Bake(MoveSpeedAuthoring authoring)
        {
            var entity = GetEntity(TransformUsageFlags.Dynamic);
            AddComponent(entity, new MoveSpeed { Value = authoring.Speed });
        }
    }
}
```

## Hybrid Approach

Mix ECS with GameObjects for incremental adoption:

- Use ECS for simulation-heavy systems (AI, pathfinding, particles)
- Keep GameObjects for UI, cameras, and player controllers
- The new Hierarchy window (opt in under Preferences > General) shows entities alongside GameObjects from Unity 6.5

## When to Use ECS

- Thousands of similar entities that need processing
- CPU-bound simulations (flocking, pathfinding, ballistics)
- Large-scale multiplayer with Netcode for Entities
- Procedural generation and world streaming

## When NOT to Use ECS

- Small games with fewer than 100 active entities
- UI-heavy applications
- Rapid prototypes where iteration speed matters more than performance
- Teams unfamiliar with data-oriented programming (learning curve is steep)

## Sources

Version-specific statements above were checked on 2026-10-10 against:

- What's new in Unity 6.4 (core ECS packages): <https://docs.unity3d.com/6000.5/Documentation/Manual/WhatsNewUnity64.html>
- What's new in Unity 6.5 (Hierarchy window): <https://docs.unity3d.com/6000.6/Documentation/Manual/WhatsNewUnity65.html>