unity-composition-pattern

Installation
SKILL.md

Unity Composition Pattern

A fundamental design skill to prevent "Inheritance Hell." This pattern replaces 10 specific classes (e.g., RedStone, GoldStone) with one generic class that composes behaviors from ScriptableObject assets.

Core Features

  1. Has-A Logic: Objects define their properties through members (Configs) rather than their base class type.
  2. SO-to-Runtime Bridge: Uses ScriptableObjects as static data templates that generate dynamic runtime instances.
  3. Tuple Deconstruction: Uses C# ValueTuples to return multi-part data from composite objects without extra boilerplate.
  4. Hierarchy Flattening: Drastically reduces the number of C# files needed by offloading variations to Project Assets.

Core Files (Max 3)

  • EntityConfigSO.cs.txt: Base class for creating interchangeable data packets.
  • ModularEntity.cs.txt: The generic container that holds one or more configurations.
  • CompositionExample.cs.txt: Demonstrates resource harvesting with Tuple destructuring.

Usage

Installs
20
GitHub Stars
9
First Seen
Apr 19, 2026
unity-composition-pattern — muharremtozan/unity-agent-skills