Unity Patterns logo

Unity Patterns

CommunityPopular
Besty0728
unity-patterns

Advise on choosing Unity design patterns

Overview

PublisherBesty0728
RepositoryUnity-Skills
Skill nameunity-patterns
Stars
1.8K
Forks
164
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by Besty0728 on GitHub. Read the source before you install it.

Installation

Install the Unity Patterns AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.

Use it in TypingMind

Enable Unity Patterns in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Unity Patterns on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Unity Patterns is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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.
  • Generics / custom attributes

    • Use when they remove repeated boilerplate with clear type safety or editor metadata value.
    • Avoid when they make gameplay code harder to read than duplicated simple code.

Decision Lab: Same Goal, Multiple Implementations

The Pattern Guide above answers "which pattern?". For most non-trivial design decisions, the better exercise is: pick the 2-3 plausible implementations, put them side by side, and compare on switch cost, query cost, code complexity, and failure modes. Below is a worked example; use it as the shape for other decisions rather than as the answer.

Worked example: "Pause AI on 100 enemies for a cutscene"

ImplementationSwitch cost (enter/exit cutscene)Per-frame cost while pausedCode complexityFailure modes
Field flag: each EnemyAI.Update starts with if (_paused) return;; manager sets the flagO(N) writes, no allocationsN branch tests + dispatch overhead per frameLowest — one bool, one guard clauseSilent bugs when a dev adds a new Update and forgets the guard
enabled = false: manager disables the MonoBehaviour on every enemyO(N) writes, no allocationsZero — Unity skips disabled Behaviours in its message listLow, but state spread across componentsOnDisable / OnEnable side effects (coroutines stop, listeners unsubscribe) may fire unexpectedly
Subset list: manager keeps _active / _frozen lists; no per-enemy Update — manager ticks only _activeO(N) list move on switchProportional to _active count only — perfect early-cullHighest — one source of truth for ownership, requires managed tickingAdding a new Update on enemies reintroduces per-frame cost; the list is easy to desync if other code respawns enemies directly

How to use

  • Pick the smallest scale where the trade-off matters. At N=5 all three are indistinguishable; at N=5000 only the subset list stays flat.
  • State what gets worse under each option, not only what improves. A table with only upsides is a sign you haven't thought about it yet.
  • The ECS lesson is that the same three shapes (value change, structural change, enableable) show up everywhere — the labels transfer even when the framework does not. Source: Dots101/Entities101/Assets/HelloCube/13. StateChange/SetStateSystem.cs:42-80 — one system dispatches to three implementations behind config.Mode, each with measurably different cost in the profiler.

When to skip this exercise

If one option is obviously bounded (N ≤ 10, state changes once per session, or the code runs once at startup), a single paragraph "we picked X because it's simplest" is enough. Decision Lab is for choices that will outlive the current task.

Output Format

  • Recommended pattern(s)
  • Why they fit this case
  • Why not the simpler alternative
  • Minimal implementation boundary
  • Known tradeoffs

Frequently asked questions

What does the Unity Patterns AI skill do?

Advise on choosing Unity design patterns

Why use Unity Patterns on TypingMind?

Because you install it once and use it with any model. Unity Patterns is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Unity Patterns in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/Besty0728/Unity-Skills/tree/main/SkillsForUnity/unity-skills~/skills/patterns. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Unity Patterns?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Unity Patterns?

As many as you like. As long as a model supports skills, you can use Unity Patterns with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Unity Patterns AI skill free?

Yes. It is published on GitHub by Besty0728 under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇