finds.dev← search

// the find

QianMo/Unity-Design-Pattern

★ 4,659 · C# · updated Feb 2020

:tea: All Gang of Four Design Patterns written in Unity C# with many examples. And some Game Programming Patterns written in Unity C#. | 各种设计模式的Unity3D C#版本实现

A Unity3D reference implementation of all 23 Gang of Four patterns plus 9 patterns from the Game Programming Patterns book, with each pattern in its own folder containing structure code, examples, and Unity scenes. It targets Unity/C# developers who want to see classic OOP patterns applied in a game engine context rather than a generic C# console app. Last touched in early 2020.

Each pattern comes with both a bare-bones structural implementation and at least one real-world game example, so you can compare the abstract skeleton against something concrete. The Game Programming Patterns section covers things GoF doesn't — object pool, dirty flag, data locality — which matter more day-to-day in Unity than most of the GoF behavioral patterns. The per-pattern Unity scenes mean you can open one folder, hit Play, and see the pattern running without wiring anything up yourself. Command pattern gets four examples including undo/redo input handling, which is actually the hard case most references skip.

Abandoned since February 2020 — Unity has changed significantly (jobs system, Burst, ECS) and none of that is reflected here, so the patterns for performance-sensitive code (data locality, object pool) are written against the old MonoBehaviour model that the job system is meant to replace. No tests anywhere; the only way to verify an example works is to open it in the Unity Editor, which makes this a read-only reference rather than something you can fork and extend with confidence. The observer pattern example ignores C# events and delegates entirely, implementing a manual subscription list instead — a beginner following it would end up writing worse code than just using `event Action`. The repo also predates Unity's own design pattern guidance, so it has no opinion on scriptable objects or the addressables patterns that Unity developers actually argue about now.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →