Open a pattern's Unity scene to see a working example before applying it in your own game
Learn how to implement an Object Pool in Unity to recycle bullets or enemies instead of creating and destroying them constantly
Study the Command pattern to add undo or input replay to a Unity game
Use the Observer pattern to build a decoupled event system so Unity game objects respond to changes without direct references
Requires Unity installed to open and run the scene examples, building from scratch needs Visual Studio with .NET support.
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.
← qianmo on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.