unity-ecs-patterns

Implements Unity ECS, Jobs, and Burst patterns for data-oriented game development.

Updated Apr 23, 2026
One-click install
npx skills add https://github.com/SanketAdlak/PDMProjectDesign --skill unity-ecs-patterns-sanketadlak
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: unity-ecs-patterns
Source: https://github.com/SanketAdlak/PDMProjectDesign/tree/main/.agents/skills/unity-ecs-patterns
Command: npx skills add https://github.com/SanketAdlak/PDMProjectDesign --skill unity-ecs-patterns-sanketadlak

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing high-performance Unity games with thousands of entities is difficult with traditional object-oriented MonoBehaviour code, which suffers from scattered memory and poor scaling. This Skill provides production-ready patterns for Unity's Data-Oriented Technology Stack (DOTS) so you can build systems that scale linearly with entity count. ## Core Features & Use Cases - ECS Architecture Patterns: Components, ISystem systems, entity queries, aspects, singletons, and entity command buffers for structural changes. - Performance Optimization: Burst-compiled jobs, IJobEntity and IJobChunk parallelization, and native collections like NativeParallelMultiHashMap for spatial hashing. - GameObject Conversion: Baking patterns that convert authoring MonoBehaviours into ECS entities with buffers and dependency tracking. - Use Case: You are building a game with 10,000 enemies on screen. Use these patterns to convert your OOP enemy logic into Burst-compiled ISystem jobs that process entities in parallel with contiguous memory access. ## Quick Start Ask the AI to convert a MonoBehaviour movement script into a Burst-compiled Unity ECS ISystem using the movement pattern.

Frequently Asked Questions about unity-ecs-patterns

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

FAQPage Schema
How do I convert Unity MonoBehaviour code to ECS?

Convert MonoBehaviours to ECS by creating an authoring component with a nested Baker class that calls AddComponent to attach IComponentData structs to the baked entity. Use GetEntity with TransformUsageFlags.Dynamic for dynamic objects and DependsOn to declare prefab dependencies.

What is the difference between ISystem and SystemBase in Unity ECS?

ISystem is an unmanaged struct-based system that is fully Burst-compatible and offers the highest performance, while SystemBase is a managed class with more flexibility but lower performance. The recommended approach is ISystem with [BurstCompile] attributes on lifecycle methods.

How do I create or destroy entities inside a Unity ECS job?

Structural changes like creating or destroying entities cannot happen directly inside jobs; use an EntityCommandBuffer instead. Get the buffer from BeginSimulationEntityCommandBufferSystem.Singleton and use its ParallelWriter with IJobEntity for parallel structural changes.

Does Unity ECS work with GameObjects and prefabs?

Yes, through the baking pipeline. Authoring MonoBehaviours with Baker classes convert GameObjects and prefabs into entities at bake time, and systems can later instantiate those baked prefab entities using EntityCommandBuffer.Instantiate.

Why does Burst compilation fail on my Unity ECS system?

Burst fails when code uses managed types such as classes, strings, or managed arrays inside compiled jobs or systems. Use only unmanaged blittable types, native collections like NativeArray, and ensure all job structs and system methods carry the [BurstCompile] attribute.

When should I not use Unity ECS for game development?

Avoid ECS for small projects, complex one-off behaviors, or UI-heavy logic where entity counts are low and OOP is simpler. ECS pays off mainly when simulating thousands of entities or optimizing CPU-bound logic that benefits from batch processing.