Community생산성 & 협업github.com

wshobson/unity-ecs-patterns

Unity ECS(Entity Component System)와 DOTS, Jobs, Burst를 활용한 고성능 게임 개발 마스터. 데이터 지향 게임 구축, 성능 최적화, 또는 대규모 엔티티 처리 시 사용하세요.

unity-ecs-patterns란 무엇인가요?

이 에이전트 기술은 Unity의 ECS(Entity Component System) 아키텍처를 중심으로 DOTS(Data-Oriented Tech Stack), Job System, Burst Compiler를 활용한 고성능 게임 개발 패턴을 제공합니다. 특히 수천 개 이상의 엔티티를 효율적으로 처리해야 하는 대규모 시뮬레이션이나 복잡한 게임 로직에서 성능 병목을 해결하는 데 초점을 맞춥니다. 주요 개발 환경인 Unity 2020 LTS 이상을 지원하며, ECS의 구조적 변경(Structural Changes), 쿼리 최적화, Job 체인 구성, Burst 호환 코드 작성 등의 핵심 개념을 단계별로 학습할 수 있습니다. 이 기술의 SKILL.md 문서는 실제 프로젝트에 바로 적용 가능한 코드 예제와 함께 데이터 지향 설계 원칙을 설명하여, 개발자들이 전통적인 객체 지향 방식에서 벗어나 더 효율적인 게임 아키텍처를 구현할 수 있도록 돕습니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/wshobson/agents/tree/main/skills/unity-ecs-patterns

Installed? Explore more 생산성 & 협업 skills: steipete/gemini, steipete/gh-issues, steipete/skill-creator · View all 6 →

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

unity-ecs-patterns은(는) 무엇을 하나요?

Unity ECS(Entity Component System)와 DOTS, Jobs, Burst를 마스터하여 고성능 게임을 개발하세요. 데이터 지향 게임을 구축하거나, 성능을 최적화하거나, 대규모 엔티티 수를 다룰 때 사용하세요.

개요

이 기술은 Unity의 ECS(Entity Component System)와 DOTS(Data-Oriented Tech Stack)를 활용한 고성능 게임 개발 패턴을 제공합니다. ECS는 전통적인 객체 지향 방식 대신 데이터 지향 설계를 사용하여 CPU 캐시 효율성을 극대화하고 병렬 처리를 최적화합니다.

주요 특징

  • 엔티티(Entity): 단순한 ID로, 데이터는 컴포넌트에 저장됩니다.
  • 컴포넌트(Component): 순수 데이터 구조체(struct)로, 로직을 포함하지 않습니다.
  • 시스템(System): 특정 컴포넌트 세트를 가진 엔티티들을 처리하는 로직입니다.

지원 환경

  • Unity 2020 LTS 이상
  • com.unity.entities 패키지
  • com.unity.jobs 패키지 (선택 사항)
  • com.unity.burst 패키지 (선택 사항)

시작하기

패키지 설치

# Unity Package Manager를 통해
com.unity.entities
com.unity.jobs
com.unity.burst

기본 ECS 예제

using Unity.Entities;
using Unity.Transforms;
using Unity.Mathematics;

// 컴포넌트 정의
public struct Speed : IComponentData
{
    public float Value;
}

// 시스템 정의 (부분 업데이트)
[UpdateInGroup(typeof(SimulationSystemGroup))]
public partial class MoveSystem : SystemBase
{
    protected override void OnUpdate()
    {
        float deltaTime = SystemAPI.Time.DeltaTime;
        
        // 모든 Translation 및 Speed 컴포넌트가 있는 엔티티 쿼리
        Entities.ForEach((ref LocalTransform transform, in Speed speed) =>
        {
            transform.Position += new float3(0, 0, speed.Value * deltaTime);
        }).ScheduleParallel();
    }
}

핵심 개념

1. 구조적 변경 (Structural Changes)

ECS에서 엔티티의 구조(추가/제거 컴포넌트, 생성/파괴 엔티티)를 변경하는 작업은 비용이 많이 들고 동기화 지점을 생성합니다.

// 엔티티 생성
EntityManager.CreateEntity(typeof(Translation), typeof(Speed));

// 컴포넌트 추가
EntityManager.AddComponent<Health>(entity);

// 엔티티 파괴
EntityManager.DestroyEntity(entity);

팁: 구조적 변경은 가능하면 적게 수행하고, EntityCommandBuffer를 사용하여 Job에서 안전하게 처리하세요.

2. Job 시스템 통합

// IJobEntity를 사용한 병렬 처리
[BurstCompile]
public partial struct MoveJob : IJobEntity
{
    public float DeltaTime;
    
    public void Execute(ref LocalTransform transform, in Speed speed)
    {
        transform.Position += new float3(0, 0, speed.Value * DeltaTime);
    }
}

// 시스템 내에서 Job 예약
protected override void OnUpdate()
{
    var job = new MoveJob { DeltaTime = SystemAPI.Time.DeltaTime };
    job.ScheduleParallel();
}

3. Burst 컴파일러

[BurstCompile] 속성을 Job에 추가하면 Burst 컴파일러가 네이티브 코드로 컴파일하여 성능을 극대화합니다.

4. 쿼리 최적화

// 특정 컴포넌트 조합 쿼리
EntityQuery query = GetEntityQuery(
    ComponentType.ReadWrite<LocalTransform>(),
    ComponentType.ReadOnly<Speed>()
);

고급 패턴

아키텍처

GameWorld
├── Systems
│   ├── InitializationSystemGroup
│   ├── SimulationSystemGroup
│   └── PresentationSystemGroup
├── Entities
└── Components

데이터 지향 설계 원칙

  • 데이터를 로직과 분리: 컴포넌트는 순수 데이터여야 합니다.
  • 캐시 지역성 활용: 관련 데이터를 연속적으로 배치하세요.
  • 병렬 처리 극대화: 시스템과 Job을 독립적으로 만들고 최대한 병렬화하세요.

문제 해결

  • 성능 문제: Profiler를 사용하여 ECS 시스템과 Job의 실행 시간을 측정하세요.
  • 구조적 변경 오류: EntityCommandBuffer를 사용하여 Job 내에서 안전하게 변경하세요.
  • Burst 호환성: Burst가 지원하지 않는 System.String이나 List<T> 같은 관리형 타입을 사용하지 마세요.

참고 자료


이 기술은 wshobson/unity-ecs-patterns 저장소를 기반으로 하며, Unity ECS와 DOTS 생태계에서 고성능 게임 개발을 위한 실질적인 패턴과 예제를 제공합니다.

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

wshobson/accessibility-compliance

Implement WCAG 2.2 compliant interfaces with mobile accessibility, inclusive design patterns, and assistive technology support. Use when auditing accessibility, implementing ARIA patterns, building for screen readers, or ensuring inclusive user experiences.

wshobson/airflow-dag-patterns

Build production Apache Airflow DAGs with best practices for operators, sensors, testing, and deployment. Use when creating data pipelines, orchestrating workflows, or scheduling batch jobs.

wshobson/angular-migration

Migrate from AngularJS to Angular using hybrid mode, incremental component rewriting, and dependency injection updates. Use when upgrading AngularJS applications, planning framework migrations, or modernizing legacy Angular code.

wshobson/anti-reversing-techniques

Understand anti-reversing, obfuscation, and protection techniques encountered during software analysis. Use this skill when analyzing malware evasion techniques, when implementing anti-debugging protections for CTF challenges, when reverse engineering packed binaries, or when building security research tools that need to detect virtualized environments.

wshobson/api-design-principles

Master REST and GraphQL API design principles to build intuitive, scalable, and maintainable APIs that delight developers. Use when designing new APIs, reviewing API specifications, or establishing API design standards.

wshobson/architecture-decision-records

Write and maintain Architecture Decision Records (ADRs) following best practices for technical decision documentation. Use when documenting significant technical decisions, reviewing past architectural choices, or establishing decision processes.

wshobson/architecture-patterns

Implement proven backend architecture patterns including Clean Architecture, Hexagonal Architecture, and Domain-Driven Design. Use this skill when designing clean architecture for a new microservice, when refactoring a monolith to use bounded contexts, when implementing hexagonal or onion architecture patterns, or when debugging dependency cycles between application layers.

wshobson/async-python-patterns

Master Python asyncio, concurrent programming, and async/await patterns for high-performance applications. Use when building async APIs, concurrent systems, or I/O-bound applications requiring non-blocking operations.

wshobson/attack-tree-construction

Build comprehensive attack trees to visualize threat paths. Use when mapping attack scenarios, identifying defense gaps, or communicating security risks to stakeholders.

wshobson/auth-implementation-patterns

Master authentication and authorization patterns including JWT, OAuth2, session management, and RBAC to build secure, scalable access control systems. Use when implementing auth systems, securing APIs, or debugging security issues.

wshobson/avoid-ai-writing

Audit and rewrite prose so it stops reading as machine-generated. Use this skill when asked to remove AI-isms, clean up AI writing, edit a draft for AI tells, audit a README, changelog, release note, PR description, or blog post for machine-sounding prose, or make text sound less like AI. Supports a detect-only mode, a rewrite mode, and an edit-in-place mode, with optional voice and context profiles.

wshobson/backtesting-frameworks

Build robust backtesting systems for trading strategies with proper handling of look-ahead bias, survivorship bias, and transaction costs. Use when developing trading algorithms, validating strategies, or building backtesting infrastructure.

wshobson/bash-defensive-patterns

Master defensive Bash programming techniques for production-grade scripts. Use when writing robust shell scripts, CI/CD pipelines, or system utilities requiring fault tolerance and safety.

wshobson/bats-testing-patterns

Master Bash Automated Testing System (Bats) for comprehensive shell script testing. Use when writing tests for shell scripts, CI/CD pipelines, or requiring test-driven development of shell utilities.

wshobson/bazel-build-optimization

Optimize Bazel builds for large-scale monorepos. Use when configuring Bazel, implementing remote execution, or optimizing build performance for enterprise codebases.

wshobson/before-you-build

Pre-build product and feature risk review for founders, product managers, and AI-assisted builders. Use this skill when the user is about to build a landing page, MVP, SaaS product, internal tool, agent workflow, or major feature and needs to check demand, positioning, monetization, retention, trust, distribution, and adoption risk before implementation starts.

wshobson/billing-automation

Build automated billing systems for recurring payments, invoicing, subscription lifecycle, and dunning management. Use when implementing subscription billing, automating invoicing, or managing recurring payment systems.

wshobson/binary-analysis-patterns

Master binary analysis patterns including disassembly, decompilation, control flow analysis, and code pattern recognition. Use when analyzing executables, understanding compiled code, or performing static analysis on binaries.

wshobson/block-no-verify-hook

Configure a PreToolUse hook to prevent AI agents from skipping git pre-commit hooks with --no-verify and other bypass flags. Use when setting up Claude Code projects that enforce commit quality gates.

wshobson/brand-landingpage

Brand-first landing page designer — runs a brand-identity interview (colors, typography, shape language), then generates and iterates on a polished landing page via Stitch with deployment-ready HTML. Use when the user asks to create, design, or build a landing page, homepage, or marketing page and has no established visual direction. Skip when they have a design mockup, need a dashboard or app UI, are working at component level, building a multi-page app, or restyling with known design tokens — use frontend-design instead.

관련 스킬