unity-patterns

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

Updated Aug 31, 2026
One-click install
npx skills add https://github.com/pikachu0310/codex-agent-ops-public --skill unity-patterns-pikachu0310
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: unity-patterns
Source: https://github.com/pikachu0310/codex-agent-ops-public/tree/main/.agents/skills/unity-skills/skills/patterns
Command: npx skills add https://github.com/pikachu0310/codex-agent-ops-public --skill unity-patterns-pikachu0310

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Choosing the wrong design pattern in Unity leads to over-engineered code, hidden coupling, and hard-to-debug systems. This Skill helps you decide whether a pattern is justified and which one fits your specific problem. ## Core Features & Use Cases - Pattern Selection Guide: Compares ScriptableObjects, C# events, event buses, interfaces, state machines, object pools, service layers, and generics with clear use/avoid criteria. - Decision Lab: Provides a worked comparison method that puts 2-3 candidate implementations side by side on switch cost, per-frame cost, code complexity, and failure modes. - Use Case: When pausing AI on 100 enemies for a cutscene, compare a field flag, disabling MonoBehaviours, and a managed subset list to pick the approach that scales to your enemy count. ## Quick Start Ask which Unity design pattern fits your problem, for example whether to use an event bus or C# events for decoupling your UI from gameplay 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 for my Unity project?

Match the pattern to the actual problem: 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 insufficient.

When should I use ScriptableObjects in Unity?

Use ScriptableObjects for authored configuration, shared static data, event channels, and reusable data assets. Avoid them as the default home for per-run mutable gameplay state, where plain class instances are clearer.

Should I use a global event bus or C# events in Unity?

Prefer C# events and delegates for one-to-many notifications with clear ownership and unsubscribe points. Reserve a global event bus for cases where many systems genuinely need broad decoupled notifications, since it hides ownership and complicates debugging.

When is an object pool worth it in Unity?

Use object pooling for frequent spawn and despawn cycles such as bullets, VFX, enemies, and UI items. Skip pooling for rare objects or simple lifetimes where instantiation cost is negligible.

How do I pause AI on many enemies efficiently in Unity?

Compare three implementations: a per-enemy paused flag, disabling the MonoBehaviour, or a manager-held active/frozen subset list. At large counts only the subset list avoids per-frame cost on frozen enemies, but it adds ownership complexity.

When should I avoid adding interfaces or state machines in Unity?

Avoid interfaces around every class without a real seam or multiple implementations. Skip state machines when a few booleans or a small command flow is enough, since the extra abstraction adds complexity without payoff.