# Unity Development Patterns

> Use when developing games with Unity engine.

- Skill: `loopyluci/unity-development-patterns` (Agent Skill)
- Install (CLI): `npx skillmds@latest add loopyluci/unity-development-patterns`
- Raw SKILL.md: https://api.skillmd.com/api/skills/loopyluci/unity-development-patterns/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- License: MIT
- Author: LoopyLuci (https://skillmd.com/u/loopyluci)
- Updated: 2026-09-08
- Page: https://skillmd.com/skills/loopyluci/unity-development-patterns

---


# Unity Development Patterns

Building games and applications with Unity — from MonoBehavior architecture and ECS/DOTS through asset management, physics, lighting, and build optimization.

## When to Use

- Building 2D/3D games with Unity
- Implementing Unity ECS (DOTS) for performance
- Managing assets, scenes, and builds
- Optimizing Unity project performance

## Unity Architecture

```csharp
// MonoBehavior component pattern
public class PlayerController : MonoBehavior
{
    [SerializeField] private float moveSpeed = 5f;
    [SerializeField] private Rigidbody rb;
    
    void Awake() => rb ??= GetComponent<Rigidbody>();
    void FixedUpdate() => HandleMovement();
    void OnCollisionEnter(Collision other) => HandleCollision(other);
    
    private void HandleMovement()
    {
        float h = Input.GetAxis("Horizontal");
        float v = Input.GetAxis("Vertical");
        rb.AddForce(new Vector3(h, 0, v) * moveSpeed);
    }
}

// DOTS ECS pattern
public struct VelocityComponent : IComponentData { public float3 Value; }
public partial struct MovementSystem : ISystem
{
    public void OnUpdate(ref SystemState state)
    {
        foreach (var (vel, trans) in 
                 SystemAPI.Query<RefRW<VelocityComponent>, RefRW<LocalTransform>>())
        {
            trans.ValueRW.Position += vel.ValueRO.Value * SystemAPI.Time.DeltaTime;
        }
    }
}
```

## Verification Checklist

- [ ] Project structure organized (Scenes, Scripts, Prefabs, Assets)
- [ ] MonoBehavior components follow single responsibility
- [ ] Physics layers and collision matrix configured
- [ ] Build settings per platform (standalone, mobile, WebGL)
- [ ] Performance profiling (frame debugger, profiler, memory)
- [ ] Asset bundle/addressable strategy for content management
- [ ] DOTS/ECS considered for CPU-intensive systems

