whatisgithub

What is unity-design-pattern?

qianmo/unity-design-pattern — explained in plain English

Analysis updated 2026-06-26

4,643C#Audience · developerComplexity · 3/5Setup · moderate

In one sentence

A Unity C# project with working implementations of all 23 classic Gang of Four design patterns plus game-specific patterns, each in its own folder with an inspectable Unity scene and a real game example.

Mindmap

mindmap
  root((Unity Design Patterns))
    Behavioral Patterns
      Observer
      Command
      State
    Structural Patterns
      Adapter
      Facade
      Proxy
    Creational Patterns
      Singleton
      Factory
      Builder
    Game Patterns
      Object Pool
      Game Loop
      Event Queue
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Open a pattern's Unity scene to see a working example before applying it in your own game

USE CASE 2

Learn how to implement an Object Pool in Unity to recycle bullets or enemies instead of creating and destroying them constantly

USE CASE 3

Study the Command pattern to add undo or input replay to a Unity game

USE CASE 4

Use the Observer pattern to build a decoupled event system so Unity game objects respond to changes without direct references

What is it built with?

C#Unity

How does it compare?

qianmo/unity-design-patternbililiverecorder/bililiverecorderautofac/autofac
Stars4,6434,6444,648
LanguageC#C#C#
Setup difficultymoderatemoderateeasy
Complexity3/52/53/5
Audiencedevelopergeneraldeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 30min

Requires Unity installed to open and run the scene examples, building from scratch needs Visual Studio with .NET support.

So what is it?

This repository contains working implementations of classic software design patterns written in C# for Unity, the game engine. Design patterns are well-known, named solutions to recurring problems in programming, and this project covers all 23 patterns from the Gang of Four, a foundational book on object-oriented software design from the 1990s that remains widely referenced today. The 23 patterns are split into three groups. Behavioral patterns deal with how objects communicate and pass responsibility, and include things like the Command pattern (storing actions as objects), the Observer pattern (notifying multiple objects when something changes), and the State pattern (changing an object's behavior based on its current state). Structural patterns deal with how objects and classes are composed, and include patterns like Adapter, Facade, and Proxy. Creational patterns deal with how objects are created, covering Singleton, Factory, Builder, and others. In addition to the Gang of Four patterns, the repository partially implements patterns from a separate book called Game Programming Patterns, which focuses on problems specific to game development. These include things like the Object Pool pattern (reusing objects instead of repeatedly creating and destroying them), the Game Loop pattern, and the Event Queue pattern. Each pattern gets its own folder. Inside, one subfolder shows a basic structural implementation of the pattern in Unity with a scene you can open and inspect. Another subfolder contains one or more real-world game examples of the pattern in action, also with a working Unity scene. The project is written in both English and Chinese. It references several well-known books and online resources as background reading, and credits an earlier Unity design pattern project as a structural influence.

Copy-paste prompts

Prompt 1
I'm building a Unity game and want to implement the Observer pattern for a health system where the UI, sound, and game manager all respond when a player takes damage. Show me a C# implementation using events or delegates
Prompt 2
How do I implement an Object Pool in Unity C# to recycle bullet prefabs instead of calling Instantiate and Destroy every frame? Include a MonoBehaviour example I can drop into a scene
Prompt 3
I want undo functionality in my Unity turn-based game. Walk me through creating an ICommand interface and a command history stack in C# based on the Command pattern
Prompt 4
Explain when to use a State pattern versus a simple enum switch in a Unity character controller, and show me a working C# State pattern for idle, walking, and attacking states

Frequently asked questions

What is unity-design-pattern?

A Unity C# project with working implementations of all 23 classic Gang of Four design patterns plus game-specific patterns, each in its own folder with an inspectable Unity scene and a real game example.

What language is unity-design-pattern written in?

Mainly C#. The stack also includes C#, Unity.

How hard is unity-design-pattern to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is unity-design-pattern for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.