Logo vun Unity Ecs Dots

Unity Ecs Dots

Organisatioun
Nice-Wolf-Studio
unity-ecs-dots

Unity 6 ECS/DOTS development guide. Use when working with Entity Component System, data-oriented design, Jobs system, or Burst Compiler. Covers Entities, IComponentData, ISystem, EntityManager, baking, Jobs, and Burst. Based on Unity 6.3 LTS documentation.

Iwwersiicht

EditeurNice-Wolf-Studio
Repositoryunity-claude-skills
Skill-Nummunity-ecs-dots
Stären
40
Forks
5
Matgeliwwert Fichieren
2
LizenzMIT
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • 2 matgeliwwert Dateien

    Skripten, Virlagen a Referenzen, déi de Modell beim Schaffe liese kann. D'Dateie kënnen nëmme gelies ginn a ginn ni ausgeféiert.

  • Open Source

    Vum Nice-Wolf-Studio op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Unity Ecs Dots an TypingMind, fir e mat all LLM ze benotzen, oder füügt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vun GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier hei drënner an a bestätegt.
    https://github.com/Nice-Wolf-Studio/unity-claude-skills/tree/main/skills/unity-ecs-dots
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill afügen → Vu GitHub-URL, pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an de Skill-Verzeechnes vun deem KI-Agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Nice-Wolf-Studio/unity-claude-skills.git /tmp/unity-claude-skills
mkdir -p .claude/skills
cp -r /tmp/unity-claude-skills/skills/unity-ecs-dots .claude/skills/unity-ecs-dots
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Unity Ecs Dots an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Unity Ecs Dots automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Unity Ecs Dots net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Keys.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

Unity ECS / DOTS (Data-Oriented Technology Stack)

Based on Unity 6.3 LTS (6000.3) -- Entities 1.3, Burst 1.8, Jobs package

Core Concepts

ECS (Entity Component System) is Unity's data-oriented framework. It replaces the GameObject/MonoBehaviour model with a cache-friendly, high-performance architecture.

ECS vs MonoBehaviour

AspectMonoBehaviourECS
IdentityGameObject (heavy, managed)Entity (lightweight int ID)
DataClass fields on componentsUnmanaged structs (IComponentData)
LogicMethods on MonoBehaviourSystems (ISystem / SystemBase)
Memory layoutScattered across heapContiguous chunks by archetype
ThreadingMain thread onlyJobs + Burst for parallel work

Entities

Entities are lightweight identifiers (an index + version integer). They have no behavior and no data -- they are handles used to associate components.

Components (IComponentData)

Components are unmanaged structs with no methods. They hold only data.

csharp
using Unity.Entities;

public struct Speed : IComponentData
{
    public float Value;
}

public struct Health : IComponentData
{
    public float Current;
    public float Max;
}

Archetypes and Chunks

An archetype is a unique combination of component types. All entities with the same set of components share an archetype. Entities are stored in chunks (16 KB blocks) grouped by archetype, enabling cache-efficient iteration.

World and EntityManager

A World contains an EntityManager and a set of systems. The default world is created automatically. EntityManager is the primary API for creating/destroying entities and adding/removing components.

Baking and SubScene Workflow

Baking converts authoring GameObjects into runtime entities. This is a one-way conversion that happens at build time or when a SubScene is loaded in the Editor.

Baker

csharp
using Unity.Entities;

// Authoring component (MonoBehaviour on GameObject)
public class SpeedAuthoring : MonoBehaviour
{
    public float speed;
}

// Baker converts authoring data to ECS components
public class SpeedBaker : Baker<SpeedAuthoring>
{
    public override void Bake(SpeedAuthoring authoring)
    {
        var entity = GetEntity(TransformUsageFlags.Dynamic);
        AddComponent(entity, new Speed { Value = authoring.speed });
    }
}

SubScene

  • SubScenes contain GameObjects that are baked into entities at build time
  • At runtime, entity data streams in efficiently (no GameObject overhead)
  • In the Editor, SubScenes can be opened for editing (shows GameObjects) or closed (shows baked entities)
  • Always place ECS-managed objects inside a SubScene

TransformUsageFlags

FlagUse
DynamicEntity moves at runtime (gets LocalTransform, LocalToWorld)
RenderableEntity is rendered but not moved by code
WorldSpaceEntity uses world-space transform only
NoneNo transform components added

Systems

Systems contain all logic. They iterate over entities that match a component query.

ISystem (Recommended)

ISystem is the modern, unmanaged system type. It is Burst-compatible and should be preferred over SystemBase.

csharp
using Unity.Burst;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Transforms;

[BurstCompile]
public partial struct MovementSystem : ISystem
{
    [BurstCompile]
    public void OnCreate(ref SystemState state)
    {
        state.RequireForUpdate<Speed>();
    }

    [BurstCompile]
    public void OnUpdate(ref SystemState state)
    {
        float deltaTime = SystemAPI.Time.DeltaTime;

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

    [BurstCompile]
    public void OnDestroy(ref SystemState state) { }
}

Key points:

  • Must be a partial struct
  • Use [BurstCompile] on the struct and each method
  • OnCreate, OnUpdate, OnDestroy receive ref SystemState
  • state.RequireForUpdate<T>() -- system only runs when T exists
  • SystemAPI.Query<T>() -- type-safe foreach iteration

SystemBase (Managed, Legacy)

SystemBase is a managed class-based system. It supports managed code but cannot be Burst-compiled at the system level. Use ISystem for all new code. SystemBase uses Entities.ForEach() lambda syntax instead of SystemAPI.Query.

SystemGroup and Update Ordering

Systems are organized into groups that update in a defined order:

InitializationSystemGroup
  -> BeginInitializationEntityCommandBufferSystem
SimulationSystemGroup (default group)
  -> BeginSimulationEntityCommandBufferSystem
  -> [Your systems go here by default]
  -> EndSimulationEntityCommandBufferSystem
PresentationSystemGroup
  -> BeginPresentationEntityCommandBufferSystem

Control ordering with attributes:

csharp
[UpdateInGroup(typeof(SimulationSystemGroup))]
[UpdateBefore(typeof(OtherSystem))]
[UpdateAfter(typeof(AnotherSystem))]
public partial struct MySystem : ISystem { }

SystemAPI

SystemAPI provides static methods for safe, Burst-compatible access:

MethodPurpose
SystemAPI.Query<T1, T2>()Iterate matching entities
SystemAPI.TimeAccess TimeData (DeltaTime, ElapsedTime)
SystemAPI.GetSingleton<T>()Get singleton component value
SystemAPI.SetSingleton<T>(value)Set singleton component value
SystemAPI.GetComponent<T>(entity)Read component from entity
SystemAPI.SetComponent<T>(entity, value)Write component on entity
SystemAPI.HasComponent<T>(entity)Check if entity has component
SystemAPI.GetComponentLookup<T>()Get random-access lookup
SystemAPI.GetBuffer<T>(entity)Get DynamicBuffer
SystemAPI.GetAspect<T>(entity)Get aspect for entity

Components Deep Dive

IComponentData (Unmanaged Struct)

The fundamental component type. Must be an unmanaged struct (no reference types, no managed arrays).

ISharedComponentData

Shared across entities -- entities with the same shared component value are grouped into the same chunk. Changing a shared component value is a structural change.

csharp
public struct TeamId : ISharedComponentData
{
    public int Value;
}

IBufferElementData (DynamicBuffer)

Variable-length arrays attached to entities.

csharp
[InternalBufferCapacity(8)]
public struct DamageEvent : IBufferElementData
{
    public float Value;
    public Entity Source;
}

// Usage in a system
foreach (var (buffer, entity) in SystemAPI.Query<DynamicBuffer<DamageEvent>>()
    .WithEntityAccess())
{
    for (int i = 0; i < buffer.Length; i++)
        totalDamage += buffer[i].Value;
    buffer.Clear();
}

ICleanupComponentData

Persists after entity destruction. Used for cleanup logic (e.g., releasing native resources). The entity is not fully destroyed until all cleanup components are removed.

IEnableableComponent

Components that can be toggled on/off without structural changes (no chunk moves).

csharp
public struct Stunned : IComponentData, IEnableableComponent { }

// Toggle in system
SystemAPI.SetComponentEnabled<Stunned>(entity, true);
bool isStunned = SystemAPI.IsComponentEnabled<Stunned>(entity);

Tag Components

Zero-size structs used purely for filtering queries. No fields -- zero memory cost per entity.

csharp
public struct IsPlayer : IComponentData { }

Common Patterns

Creating and Destroying Entities

csharp
// Direct creation (structural change -- main thread only)
Entity e = entityManager.CreateEntity(typeof(Speed), typeof(Health));

// Preferred: use EntityCommandBuffer for deferred structural changes
var ecb = new EntityCommandBuffer(Allocator.TempJob);
Entity e2 = ecb.CreateEntity();
ecb.AddComponent(e2, new Speed { Value = 5f });
ecb.Playback(entityManager);
ecb.Dispose();

EntityCommandBuffer (ECB)

Structural changes (create/destroy entity, add/remove component) cannot happen during iteration. Use ECB to defer them. See references/ecs-api.md for full ECB API.

System-Managed ECB (Preferred)

csharp
[BurstCompile]
public partial struct SpawnSystem : ISystem
{
    [BurstCompile]
    public void OnUpdate(ref SystemState state)
    {
        var ecbSingleton = SystemAPI.GetSingleton<
            EndSimulationEntityCommandBufferSystem.Singleton>();
        var ecb = ecbSingleton.CreateCommandBuffer(state.WorldUnmanaged);
        // ecb is played back automatically -- no Playback/Dispose needed
        foreach (var spawner in SystemAPI.Query<RefRW<Spawner>>())
        {
            if (spawner.ValueRO.Timer <= 0)
            {
                ecb.Instantiate(spawner.ValueRO.Prefab);
                spawner.ValueRW.Timer = spawner.ValueRO.Interval;
            }
        }
    }
}

Singleton Components

Use when exactly one entity has a given component. Access via SystemAPI.GetSingleton<T>() / SystemAPI.SetSingleton<T>(value) / SystemAPI.GetSingletonRW<T>(). Useful for global config, game state, and similar one-of-a-kind data.

Aspects (IAspect)

Aspects group related components into a single access wrapper with optional methods.

csharp
public readonly partial struct CharacterAspect : IAspect
{
    public readonly RefRW<LocalTransform> Transform;
    public readonly RefRO<Speed> Speed;
    public readonly RefRW<Health> Health;

    public void Move(float3 direction, float deltaTime)
    {
        Transform.ValueRW.Position +=
            direction * Speed.ValueRO.Value * deltaTime;
    }
}

// Use in system
foreach (var character in SystemAPI.Query<CharacterAspect>())
{
    character.Move(new float3(1, 0, 0), deltaTime);
}

Jobs System

IJobEntity (Recommended)

Automatically generates an EntityQuery from the Execute parameter types.

csharp
[BurstCompile]
public partial struct MoveJob : IJobEntity
{
    public float DeltaTime;

    void Execute(ref LocalTransform transform, in Speed speed)
    {
        transform.Position += new float3(0, 0, speed.Value * DeltaTime);
    }
}

// Schedule from system
[BurstCompile]
public partial struct MoveSystem : ISystem
{
    [BurstCompile]
    public void OnUpdate(ref SystemState state)
    {
        new MoveJob
        {
            DeltaTime = SystemAPI.Time.DeltaTime
        }.ScheduleParallel();
    }
}

IJobChunk (Low-Level)

Manual chunk iteration for maximum control. See references/jobs-burst.md for full examples.

Job Scheduling

MethodBehavior
Run()Execute on main thread (no job scheduling)
Schedule()Single-threaded job on worker thread
ScheduleParallel()Multi-threaded across chunks

ECB in Parallel Jobs

csharp
[BurstCompile]
public partial struct DestroyDeadJob : IJobEntity
{
    public EntityCommandBuffer.ParallelWriter ECB;

    void Execute([ChunkIndexInQuery] int sortKey, in Health health, Entity entity)
    {
        if (health.Current <= 0)
            ECB.DestroyEntity(sortKey, entity);
    }
}

Burst Compiler

The Burst compiler translates IL/.NET bytecode into highly optimized native code using LLVM.

Usage

Add [BurstCompile] to ISystem structs (and each method) and IJobEntity structs. Burst compiles them to optimized native code via LLVM.

Restrictions

  • No managed types (no class, string, List<T>, managed arrays)
  • No allocations (no new for reference types)
  • No try/catch/finally
  • No virtual methods or interfaces (except job interfaces)
  • No static mutable fields (use SharedStatic<T> instead)
  • Must use NativeContainer types for collections

Unity.Mathematics

Burst-optimized math library replacing UnityEngine.Mathf and Vector3:

csharp
using Unity.Mathematics;

float3 position = new float3(1, 2, 3);
quaternion rot = quaternion.Euler(0, math.PI, 0);
float dist = math.distance(a, b);
float3 dir = math.normalize(b - a);
float val = math.lerp(0f, 1f, 0.5f);
UnityEngineUnity.Mathematics
Vector3float3
Vector2float2
Quaternionquaternion
Mathf.Lerpmath.lerp
Mathf.Sinmath.sin
Matrix4x4float4x4

Anti-Patterns

WhatWhy It's WrongFix
Using SystemBase when ISystem worksCannot Burst-compile system, heap allocationsUse ISystem (partial struct) with [BurstCompile]
Structural changes during iterationInvalidates iterators, causes exceptionsUse EntityCommandBuffer for deferred changes
Structural changes in parallel jobs without ECBRace conditions, crashesUse EntityCommandBuffer.ParallelWriter with sort key
Managed types in Burst-compiled codeBurst cannot compile managed typesUse unmanaged structs, FixedString, NativeContainer
Missing [BurstCompile] on ISystemSystem runs as managed code, loses performanceAdd [BurstCompile] to struct and all methods
Allocating NativeArray every frame without disposingMemory leakAllocate with Allocator.Temp or dispose in OnDestroy
Using UnityEngine.Mathf in Burst codeNot Burst-optimizedUse Unity.Mathematics.math
Forgetting state.RequireForUpdate<T>()System runs even when no matching entities existCall in OnCreate to skip updates when unnecessary
Modifying SharedComponentData frequentlyEach change is a structural change (chunk move)Use regular IComponentData for frequently changing data
Using GetComponent in inner loopsRandom access breaks cache coherencyUse SystemAPI.Query for linear iteration

Key API Quick Reference

Class / StructKey MembersNotes
EntityManagerCreateEntity, DestroyEntity, AddComponent<T>, RemoveComponent<T>, GetComponentData<T>, SetComponentData<T>Main-thread only; structural changes
EntityCommandBufferCreateEntity, DestroyEntity, AddComponent, RemoveComponent, Instantiate, PlaybackDeferred structural changes
ECB.ParallelWriterSame as ECB but with sortKey parameterThread-safe for parallel jobs
SystemAPIQuery<T>, Time, GetSingleton<T>, GetComponent<T>, GetComponentLookup<T>Static access from systems
EntityQueryToEntityArray, ToComponentDataArray<T>, CalculateEntityCountBulk operations
IComponentData(marker interface)Unmanaged struct components
IBufferElementData(marker interface)Dynamic buffer elements
DynamicBuffer<T>Add, RemoveAt, Length, Clear, AsNativeArrayVariable-length per-entity arrays
IJobEntityExecute(ref T1, in T2, ...)Auto-generated query from params
IJobChunkExecute(in ArchetypeChunk, ...)Manual chunk iteration
WorldDefaultGameObjectInjectionWorld, EntityManagerContainer for systems + entities
RefRW<T> / RefRO<T>ValueRW / ValueRORead-write / read-only component refs

Related Skills

  • unity-scripting -- MonoBehaviour scripting, coroutines, async/await
  • unity-physics -- Physics engine, Rigidbody, colliders (for Unity Physics ECS package)
  • unity-foundations -- GameObjects, Transforms, Scenes, Prefabs

Additional Resources

Matgeliwwert Fichieren

De Modell liest dës Dateie bei Bedarf, wärend de Skill gelueden ass. Si ginn als liesbar Dateie bereetgestallt a ginn ni ausgeféiert.

Heefeg gestallte Froen

Wat mécht de KI-Skill Unity Ecs Dots?

Unity 6 ECS/DOTS development guide. Use when working with Entity Component System, data-oriented design, Jobs system, or Burst Compiler. Covers Entities, IComponentData, ISystem, EntityManager, baking, Jobs, and Burst. Based on Unity 6.3 LTS documentation.

Firwat Unity Ecs Dots op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Unity Ecs Dots besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt amplaz vun engem Abonnement pro Benotzerplaz. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Unity Ecs Dots an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/Nice-Wolf-Studio/unity-claude-skills/tree/main/skills/unity-ecs-dots an. TypingMind liest d'Datei SKILL.md, bündelt déi zougehéiereg Dateien an installéiert dat Ganzt als Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Unity Ecs Dots benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Unity Ecs Dots benotzen?

Esou vill Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Unity Ecs Dots domat benotzen – GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama a méi – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Unity Ecs Dots gratis?

Jo. De Skill gëtt vum Nice-Wolf-Studio ënner der Lizenz MIT op GitHub publizéiert. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbaart Pak vun Instruktiounen, dat engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt en nokënnt a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a keng Lafzäitëmfeld a funktionéiere mat all Modell.

All weisen

Elo Ären eegene KI-Workspace ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇