unity-patterns

A guide for choosing software design patterns in Unity, a game-development platform. It covers approaches such as events, state machines, object pools, and shared data assets.

In plain words
What is it for?
It is for structuring loosely connected Unity systems and choosing between event-based, state-based, pooling, and configuration approaches.
Why use it?
It helps decide whether a pattern fits a problem and avoids adding complicated structures when simpler code is enough.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/besty0728/unity-skills/patterns
Any agent
npx skills add Besty0728/Unity-Skills --skill patterns
Clone the repo
git clone --depth 1 https://github.com/Besty0728/Unity-Skills

Made for: Claude Code, Codex.

Per session 11 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,162 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00011 $0.01162
Opus 5 $0.00005 $0.00581
Sonnet 5 $0.00002 $0.00232
Haiku 4.5 $0.00001 $0.00116

Measured 2d ago against content hash b8f99a0b6abd, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

unity-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

SkillsForUnity/unity-skills~/skills/patterns/SKILL.md · 87 lines

How it starts

The opening of the file, as written. The whole thing — 87 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Before calling any skill in this module: if you are about to call a skill with parameters guessed from its name or description, STOP — read this file (or fetch its schema via GET /skills/recommend?includeSchema=true) first. If you already have the parameter definitions from recommend/schema, you may proceed straight to dryRun.

Triggers

  • Deciding which pattern fits a problem
  • Structuring decoupled systems
  • Choosing event/state-machine/pool approaches
  • 判断哪种模式适合某问题、构建解耦系统、在事件/状态机/对象池方案间抉择

Unity Pattern Selector

Use this skill to decide whether a pattern is justified. Do not recommend every pattern at once.

Guardrails

Mode: Documentation only — no REST skills to gate; load freely under any operating mode (Approval / Auto / Bypass).

  • Recommend at most 1-3 patterns, and explain why simpler options are not enough.

Pattern Guide

  • ScriptableObject

    • Use for authored config, shared static data, event channels, and reusable data assets.
    • Avoid as the default home for per-run mutable gameplay state.
  • C# events / delegates

    • Use for one-to-many notifications with clear ownership and unsubscribe points.
    • Avoid for imperative flows that need ordering, return values, or complex debugging.
  • Global event bus / observer hub

    • Use sparingly and only when many systems truly need broad decoupled notifications.
    • Avoid as the default answer to coupling. It often hides ownership and makes debugging harder.
  • Interfaces

    • Use when multiple implementations or clearer dependency boundaries are needed.
    • Avoid adding interfaces around every class without a real seam.
  • State machine

    • Use for actors with mutually exclusive states and explicit transitions.
    • Avoid when a few booleans or a small command flow is enough.
  • Object pool

    • Use for frequent spawn/despawn of bullets, VFX, enemies, UI items.
    • Avoid for rare objects or when lifetime is simple.
  • Service layer

    • Use for a small number of cross-scene systems with explicit bootstrap and interfaces.
    • Avoid turning everything into hidden singletons or service locators.

Read the full file on GitHub · 87 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 87 lines · 11 tokens per session scan A b8f99a0b6abd

Subscribe to this mod's changes

unity-patterns is a skill published in the GitHub repository Besty0728/Unity-Skills (1,695 stars, last pushed today), licensed MIT. It adds 11 tokens to every session and 1,162 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

2dimg2motion

Use when a user provides one baseline image and requests game animation frames, sprite sequences, attack/walk/idle/hit/death/casting motion, transparent PNG frames, a spritesheet, keyframe prompts, or consistent whole-character pose animation.

WU-HAOTIAN34/2dimg2motion · 55 tokens

dotcraft-unity

Use when dotcraft-unity MCP or unityexecutecsharp is available, or when the user asks to inspect, automate, capture, or debug Unity Editor state, scenes, assets, Console logs, or GameView output. Provides background-first Unity Editor automation rules.

DotHarness/dotcraft-unity · 58 tokens

img2mo-learn

Learn reusable 2D motion-generation knowledge from user-specified action resources with /img2mo-learn . Use when the user provides videos, extracted frame sequences, spritesheets, Spine assets, generated outputs, failed attempts, or reference motion folders and wants to summarize animation timing, pose beats, style…

WU-HAOTIAN34/2dimg2motion · 104 tokens

img2mo-std

Standardize a 2D animation baseline image with /img2mo-std xxx.png/pos. Use when preparing a character, creature, prop, or weapon baseline before motion generation, especially if the source image is too large, tightly cropped, lacks transparent action margin, has a white background, or later walk/attack/idle frames…

WU-HAOTIAN34/2dimg2motion · 87 tokens

zu-article-image-skill

为已完成的 Markdown 文章设计语义配图位置,按内置 preset/type/style/palette 样式体系生成可编辑自然语言生图 Prompt,并作为隐藏标签插入文章;用户确认后扫描标签,调用当前运行时原生 imagegen 生成图片并插回文章。用于用户要求为文章配图、规划正文插图、调整文章插图风格或根据文章内 Prompt 标签生成图片时。.

wwenj/zu-article-image-skill · 100 tokens

msh-exam-analysis

名师汇出国自动化工具集。两个功能:(1) 模考错题分析——用户提供 mingshihuichuguo.com/homework/student/ 网址,按"手写版"人味风格产出阅读/听力错题分析 txt;(2) 单词听写自动化——用户要求完成 list 听写/单词测试时,用 playwright-cli + runv5.js 自动答题。根据用户意图自动判断用哪个。When the user mentions 错题分析 / 模考 / 听写 / 单词 / list / mingshihuichuguo URL, use this skill.

JiHuiYiYou/msh-skill · 144 tokens