Skills unity-ecs-patterns
📦

unity-ecs-patterns

Safe

Implement Unity ECS Patterns

Building high-performance Unity games requires specialized data-oriented patterns that traditional OOP cannot provide. This skill provides production-ready ECS patterns using DOTS, Jobs, and Burst for games that scale to thousands of entities.

Supports: Claude Codex Code(CC)
📊 69 Adequate
1

Download the skill ZIP

2

Upload in Claude

Go to Settings → Capabilities → Skills → Upload skill

3

Toggle on and start using

Test it

Using "unity-ecs-patterns". Create an ECS component for player health with current and max values, and a system that heals players over time.

Expected outcome:

  • Component Definition:
  • ```csharp
  • public struct Health : IComponentData
  • {
  • public float Current;
  • public float Max;
  • }
  • ```
  •  
  • Healing System:
  • ```csharp
  • [BurstCompile]
  • public partial struct HealthRegenSystem : ISystem
  • {
  • public void OnUpdate(ref SystemState state)
  • {
  • float deltaTime = SystemAPI.Time.DeltaTime;
  • float regenRate = 5f;
  •  
  • foreach (var health in
  • SystemAPI.Query<RefRW<Health>>())
  • {
  • health.ValueRW.Current = math.min(
  • health.ValueRO.Max,
  • health.ValueRO.Current + regenRate * deltaTime
  • );
  • }
  • }
  • }
  • ```

Using "unity-ecs-patterns". How do I convert a GameObject to an entity with authoring?

Expected outcome:

  • 1. Create an Authoring MonoBehaviour:
  • ```csharp
  • public class EnemyAuthoring : MonoBehaviour
  • {
  • public float Speed;
  • public float Health;
  •  
  • class Baker : Baker<EnemyAuthoring>
  • {
  • public override void Bake(EnemyAuthoring authoring)
  • {
  • var entity = GetEntity(TransformUsageFlags.Dynamic);
  • AddComponent(entity, new Speed { Value = authoring.Speed });
  • AddComponent(entity, new Health { Current = authoring.Health, Max = authoring.Health });
  • }
  • }
  • }
  • ```
  •  
  • 2. Add the authoring component to a GameObject in the Editor
  • 3. The baking system automatically converts it to an entity at build time

Using "unity-ecs-patterns". Write a parallel job that damages all enemies in a radius around each entity.

Expected outcome:

This requires a spatial hash approach. First, build a spatial hash map in a parallel job. Then run a second pass that queries nearby cells and applies damage. The spatial hash function uses prime number multiplication for uniform distribution: `hash = x * 73856093 ^ y * 19349663 ^ z * 83492791`.

Security Audit

Safe
v5 • 1/21/2026

All 59 static findings are false positives. The skill contains Unity ECS documentation with code examples. Detected patterns (hash functions, system API references, backticks) are legitimate game development patterns and Markdown formatting, not security threats.

2
Files scanned
1,194
Lines analyzed
0
findings
5
Total audits
No security issues found
Audited by: claude View Audit History →

Quality Score

38
Architecture
100
Maintainability
87
Content
21
Community
100
Security
87
Spec Compliance

What You Can Build

Indie Game Developer Building Performance-Critical Games

Create efficient game systems that handle thousands of enemies, particles, or units without performance degradation using ECS patterns.

Gameplay Programmer Learning DOTS

Transition from traditional Unity MonoBehaviour patterns to data-oriented ECS architecture with guided examples and best practices.

Technical Artist Creating Particle Systems

Build massive particle and effect systems that process in parallel using Jobs and Burst compilation for GPU-like performance on CPU.

Try These Prompts

Basic ECS Component
Create a Speed component and a MovementSystem in Unity ECS using ISystem and BurstCompile. The system should move entities forward based on their speed value.
Entity Spawning System
Write a SpawnSystem that uses EntityCommandBuffer to create entities at runtime with a Spawner component. Include both single-threaded and parallel job versions.
Aspect-Based Character
Create a CharacterAspect that groups Health, Speed, and LocalTransform components. Include a method to apply damage that respects shield absorption logic.
Spatial Hash System
Build a spatial hashing system using NativeParallelMultiHashMap for efficient collision queries. Include the hash function and parallel job for updating the spatial grid.

Best Practices

  • Use ISystem instead of SystemBase for maximum performance and Burst compatibility
  • Always apply [BurstCompile] to jobs and systems for optimal performance
  • Defer structural changes (create/destroy/add) using EntityCommandBuffer to avoid breaking job scheduling

Avoid

  • Avoid adding managed types (classes, strings, arrays) to components as they break Burst compilation
  • Do not perform structural changes inside parallel jobs; use EntityCommandBuffer.ParallelWriter instead
  • Avoid querying entities one-by-one; use entity queries and ToComponentDataArray for batch operations

Frequently Asked Questions

What Unity version supports ECS?
Unity 2022.2 LTS and newer have stable DOTS support. Install the Entities and Burst packages via Package Manager.
How is ECS different from MonoBehaviour?
ECS separates data (components) from behavior (systems). Components are simple structs with no methods. Systems contain logic. This enables cache-friendly memory layouts and parallel processing.
Can I mix ECS with traditional GameObjects?
Yes, use the Hybrid Renderer and authoring components to convert GameObjects to entities. For runtime interactions, use SystemAPI.GetComponent on entities and GameObject manipulation for hybrid approaches.
What is Burst and why should I use it?
Burst is a compiler that optimizes C# code using LLVM. It produces highly optimized native machine code. Always apply [BurstCompile] to jobs and systems for 10x+ performance improvements.
How many entities can ECS handle?
ECS can handle 100,000+ entities on modern hardware. Performance depends on cache locality, job efficiency, and avoiding main-thread bottlenecks. Profile to identify limits.
Should I use Aspects or direct component access?
Aspects improve code organization when querying the same component combination across multiple systems. For simple queries, direct access via SystemAPI.Query is clearer.

Developer Details

File structure

📄 SKILL.md