unity-patterns

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

Updated May 20, 2026
One-click install
npx skills add https://github.com/yuse168/Roomies --skill unity-patterns-yuse168
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: unity-patterns
Source: https://github.com/yuse168/Roomies/tree/main/.agents/skills/unity-skills/skills/patterns
Command: npx skills add https://github.com/yuse168/Roomies --skill unity-patterns-yuse168

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. 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 ScriptableObject, C# events, event buses, interfaces, state machines, object pools, service layers, and generics with explicit use/avoid criteria. - Decision Lab: Provides a side-by-side comparison method (switch cost, per-frame cost, complexity, failure modes) for non-trivial design decisions, illustrated with a worked example of pausing 100 enemies. - Structured Output: Delivers recommended patterns, why they fit, why simpler alternatives fall short, minimal implementation boundaries, and known tradeoffs. - Use Case: When you ask "should I use a state machine for my enemy AI" or "用什么模式管理游戏配置", the Skill recommends at most 1-3 justified patterns instead of listing everything. ## Quick Start Ask the assistant which Unity design pattern fits your problem, for example whether to use an event bus or direct C# events for UI-to-gameplay communication.

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?▼

Compare the 2-3 plausible implementations side by side on switch cost, per-frame cost, code complexity, and failure modes. Recommend at most 1-3 patterns and explain why simpler options like booleans or direct references are not enough for your case.

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 state machine for Unity enemy AI?▼

Use a state machine when actors have mutually exclusive states with explicit transitions. If a few booleans or a small command flow covers the behavior, a full state machine adds unnecessary complexity.

Event bus vs C# events in Unity, which is better?▼

C# events suit one-to-many notifications with clear ownership and unsubscribe points. A global event bus is only justified when many systems truly need broad decoupled notifications, since it hides ownership and complicates debugging.

When should I use object pooling in Unity?▼

Use object pooling for frequent spawn and despawn of bullets, VFX, enemies, or UI items where allocation churn matters. Avoid it for rare objects or simple lifetimes where Instantiate and Destroy are sufficient.

What are the downsides of a global event bus in Unity?▼

A global event bus hides ownership, makes event flows hard to trace, and complicates debugging when used as the default answer to coupling. It should be used sparingly and only for genuinely broad cross-system notifications.