34 patterns · live demos · real C#

Unity Design Patterns

C# game programming patterns, explained with interactive animations you can poke at — and production-style Unity code you can drop into your project.

Game Programming

Patterns born in game engines: loops, components, data-driven design and Unity’s ScriptableObjects.

11

Game Loop

Advance the game in steady time steps, decoupled from how fast the machine can render frames.

Open demo →

Update Method

Give every entity a per-frame method and let the game loop call it, so each object simulates one frame of its own behaviour.

Open demo →

Component

Build entities by attaching small, single-purpose pieces of behaviour instead of growing a deep inheritance tree.

Open demo →

Type Object

Describe each kind of thing as a data object, so new kinds are assets instead of new subclasses.

Open demo →

Subclass Sandbox

Give a base class a small toolbox of protected operations and write every subclass only in terms of that toolbox.

Open demo →

Double Buffer

Read from a finished copy of the state and write into a second copy, then swap them, so an update never sees its own half-done work.

Open demo →

Event Queue

Separate the moment a request is sent from the moment it is handled, so bursts are buffered, merged and processed at a steady pace.

Open demo →

Event Bus

A global, typed publish/subscribe hub where publishers and subscribers share only event types, never references to each other.

Open demo →

ScriptableObject Events

Turn events into ScriptableObject assets, so scene objects and prefabs talk through a shared file wired in the Inspector instead of through each other.

Open demo →

ScriptableObject Variables

Store shared values like player health in assets, so writers and readers meet at the data instead of at each other.

Open demo →

Runtime Sets

Keep a live list of scene objects in a ScriptableObject that the objects maintain themselves, so nobody has to search the scene.

Open demo →