unity-patterns

Advises on selecting Unity design patterns for decoupled game architecture decisions.

Updated Jun 21, 2026
One-click install
npx skills add https://github.com/du-qwq/Shader-Writing-Architecture-and-Specifications --skill unity-patterns-du-qwq
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: unity-patterns
Source: https://github.com/du-qwq/Shader-Writing-Architecture-and-Specifications/tree/main/.agents/skills/unity-skills/skills/patterns
Command: npx skills add https://github.com/du-qwq/Shader-Writing-Architecture-and-Specifications --skill unity-patterns-du-qwq

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Choosing the right design pattern in Unity is hard: overusing event buses, singletons, or state machines leads to hidden coupling and debugging pain, while under-engineering leaves systems brittle. This Skill helps you decide which pattern actually fits your problem and when a simpler approach is enough. ## Core Features & Use Cases - Pattern Selection Guidance: Compares ScriptableObjects, C# events, event buses, interfaces, state machines, object pools, service layers, and generics with explicit use/avoid criteria. - Decision Lab Method: Provides a side-by-side comparison framework (switch cost, per-frame cost, complexity, failure modes) for non-trivial design decisions, illustrated with a worked example of pausing 100 enemies during a cutscene. - Use Case: When you ask "should I use a state machine for my enemy AI?" or "how do I decouple my UI from gameplay systems?", the Skill recommends at most 1-3 patterns, explains why simpler options fall short, and lists known tradeoffs. ## Quick Start Ask the AI which Unity design pattern fits your problem, for example whether to use an event bus or direct C# events for decoupling your inventory and UI systems.

Frequently Asked Questions about unity-patterns

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

FAQPage Schema
How do I choose the right design pattern in Unity?

Match the pattern to the problem shape: ScriptableObjects for shared config data, C# events for one-to-many notifications, state machines for mutually exclusive states, and object pools for frequent spawning. Recommend at most 1-3 patterns and explain why simpler options are not enough.

When should I use a state machine in Unity?

Use a state machine when an actor has mutually exclusive states with explicit transitions, such as enemy AI behaviors. Avoid it when a few booleans or a small command flow is sufficient, since the added structure only pays off at real complexity.

Should I use a global event bus in Unity?

Use a global event bus sparingly, only when many systems genuinely need broad decoupled notifications. It often hides ownership and makes debugging harder, so prefer direct C# events with clear subscribe and unsubscribe points first.

When is object pooling worth it in Unity?

Object pooling pays off for frequent spawn and despawn cycles like bullets, VFX, enemies, and UI items. Avoid it for rare objects or simple lifetimes, where Instantiate and Destroy are cheaper to maintain than pool bookkeeping.

Are ScriptableObjects good for runtime game state?

ScriptableObjects are best for authored config, shared static data, event channels, and reusable data assets. Avoid them as the default home for per-run mutable gameplay state, since asset persistence can leak state between play sessions.