unity-patterns

Recommend Unity design patterns for specific gameplay or system problems.

Updated Apr 15, 2026
One-click install
npx skills add https://github.com/Yuan-Zzzz/FrogRE --skill unity-patterns-yuan-zzzz
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: unity-patterns
Source: https://github.com/Yuan-Zzzz/FrogRE/tree/main/.codex/skills/unity-skills/skills/patterns
Command: npx skills add https://github.com/Yuan-Zzzz/FrogRE --skill unity-patterns-yuan-zzzz

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It helps Unity developers decide which design pattern to apply for a given gameplay or system problem, reducing unnecessary complexity and preventing architectural anti-patterns.

Core Features & Use Cases

  • Pattern selection: Recommends 1–3 appropriate patterns such as ScriptableObject, C# events/delegates, observer hubs, state machines, object pools, interfaces, or service layers.
  • Rationale and tradeoffs: Explains why the recommended patterns fit and why simpler alternatives are insufficient.
  • Minimal implementation boundary: Describes the smallest viable implementation surface and key integration points.
  • Use case example: Choosing between an object pool or transient instantiation for high-frequency spawns, or deciding when to use ScriptableObjects for shared config versus runtime state.

Quick Start

Recommend 1-2 Unity design patterns for a player ability system that requires modular configuration, deterministic state transitions, and frequent object spawning.

Frequently Asked Questions about unity-patterns

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

FAQPage Schema
When should I use ScriptableObjects versus plain C# classes for configuration in Unity?

Use ScriptableObjects for shared configuration data that remains static during runtime, while plain C# classes are better for managing mutable runtime state. This separation prevents architectural anti-patterns by keeping data persistence and gameplay logic distinct.

What is the best way to manage high-frequency object spawning in Unity?

Object pooling is the best way to manage high-frequency spawning in Unity. It pre-instantiates reusable objects, avoiding the performance overhead of transient instantiation and reducing garbage collection spikes during active gameplay.

How do I choose between C# events and an observer hub for my Unity event system?

Choose C# events for simple, localized notifications within a single system, and an observer hub for broader, decoupled communication across multiple systems. The observer pattern prevents tight coupling when many unrelated scripts need to listen to global state changes.

Can I use a state machine for player ability systems with deterministic transitions?

Yes, you can use a state machine for player ability systems to enforce deterministic state transitions. It structures complex ability logic into discrete states, preventing invalid transitions and making the modular configuration of abilities much easier to maintain.

Do I need a service layer or singletons to decouple systems in my Unity project?

You need a service layer to decouple systems with clear interfaces, whereas singletons often create hidden global dependencies. Choosing a service layer over singletons during refactor decisions reduces unnecessary complexity and prevents architectural anti-patterns.