unity-dots-ecs
БесплатноБез исполняемых скриптовНе проверенUse when working in a Unity project that uses Entities (DOTS) or when a task needs thousands of simulated objects - when ECS is worth it…
от makifbaysal★ 123 звезды на GitHubОб этом скилле
Unity DOTS / ECS
Overview
Unity's Entities package stores data in tightly packed chunks and runs Burst-compiled jobs over it in parallel. It scales to tens of thousands of entities where GameObjects choke — and it makes simple gameplay code more verbose. Use it where the scale needs it, follow the project's existing split between GameObjects and entities, and never introduce DOTS into a GameObject project on your own initiative.
Core principle: Components are plain data, systems are Burst-compiled ISystems scheduling jobs, and structural changes go through an entity command buffer.
When it is worth it
| Situation | Use |
|---|---|
| Thousands of similar units, projectiles, boids, crowd agents | ECS (or Jobs + Burst over native arrays first) |
| Heavy simulation with little per-object uniqueness | ECS |
| UI, menus, a handful of characters, bespoke scripted moments | GameObjects |
| Mixed game | Hybrid: entities for the swarm, GameObjects for the player, UI and cameras |
The pieces
// Data: unmanaged structs
public struct Speed : IComponentData { public float Value; }
public struct Target : IComponentData { public float3 Position; }
// Authoring + baking: designers edit a MonoBehaviour in a subscene; the baker turns it into components
public sealed class SpeedAuthoring : MonoBehaviour {
public float value = 5f;
sealed class Baker : Baker<SpeedAuthoring> {
public override void Bake(SpeedAuthoring a) {
var e = GetEntity(TransformUsageFlags.Dynamic);
AddComponent(e, new Speed { Value = a.value });
}
}
}
// Behaviour: a Burst-compiled ISystem scheduling a parallel IJobEntity
[BurstCompile]
public partial struct SeekSystem : ISystem {
[BurstCompile] public void OnCreate(ref SystemState state) => state.RequireForUpdate<Speed>();
[BurstCompile] public void OnUpdate(ref SystemState state) {
new SeekJob { Dt = SystemAPI.Time.DeltaTime }.ScheduleParallel();
}
}
[BurstCompile]
partial struct SeekJob : IJobEntity {
public float Dt;
void Execute(ref LocalTransform transform, in Speed speed, in Target target) {
var to = target.Position - transform.Position;
var dist = math.length(to);
if (dist > 0.01f) transform.Position += to / dist * math.min(speed.Value * Dt, dist);
}
}
Rules
ISystemwith[BurstCompile]overSystemBasefor new systems;SystemBaseonly where managed objects are unavoidable.- Burst everything on the hot path: no managed types (classes, strings,
List<T>) in components or jobs that should be Burst-compiled; useFixedString,NativeArray,DynamicBuffer. infor read-only,reffor written components inExecute— it drives the dependency system and parallelism.- Structural changes (create/destroy entities, add/remove components) are recorded in an entity command buffer, not done inside jobs:
var ecb = SystemAPI.GetSingleton<EndSimulationEntityCommandBufferSystem.Singleton>()
.CreateCommandBuffer(state.WorldUnmanaged).AsParallelWriter();
new ExpireJob { Ecb = ecb, Now = (float)SystemAPI.Time.ElapsedTime }.ScheduleParallel();
// in the job: void Execute([ChunkIndexInQuery] int key, Entity e, in Lifetime l) { if (Now > l.EndsAt) Ecb.DestroyEntity(key, e); }
- Frequent on/off states use enableable components (
IEnableableComponent) instead of add/remove, which moves the entity between chunks. - Archetype hygiene: many tiny component combinations fragment chunks; check chunk utilisation in the Entities windows.
- Native memory: every
NativeArray/NativeListis disposed —Allocator.Tempinside a frame,TempJobwithin four frames,PersistentinOnDestroy. Leak warnings are bugs. - Aspects (
IAspect) are deprecated in recent Entities releases — use explicit component parameters and queries instead of adding new ones. - Physics (Unity Physics / Havok) runs in its own fixed-step group — gameplay that reacts to physics runs in or after that group, not in an arbitrary
Updatesystem.
Testing systems
public class SeekSystemTests {
World _world; EntityManager _em;
[SetUp] public void SetUp() { _world = new World("Test"); _em = _world.EntityManager; }
[TearDown] public void TearDown() => _world.Dispose();
[Test] public void Update_EntityWithSpeed_MovesTowardTarget() {
var e = _em.CreateEntity(typeof(LocalTransform), typeof(Speed), typeof(Target));
_em.SetComponentData(e, LocalTransform.FromPosition(float3.zero));
_em.SetComponentData(e, new Speed { Value = 2f });
_em.SetComponentData(e, new Target { Position = new float3(10, 0, 0) });
var system = _world.CreateSystem<SeekSystem>();
_world.SetTime(new TimeData(elapsedTime: 0.5, deltaTime: 0.5f));
system.Update(_world.Unmanaged);
_em.CompleteAllTrackedJobs();
Assert.That(_em.GetComponentData<LocalTransform>(e).Pos
Установить unity-dots-ecs в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл unity-dots-ecs?
Use when working in a Unity project that uses Entities (DOTS) or when a task needs thousands of simulated objects - when ECS is worth it, components/bakers/ISystem with IJobEntity and Burst, entity command buffers for structural changes, native memory rules, and testing systems in a test World.
Как установить скилл unity-dots-ecs?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл unity-dots-ecs запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic