muharremtozan/unity-agent-skills

unity-composition-pattern

Implements "Composition over Inheritance" using ScriptableObject configs and C# Tuples. Replaces deep class hierarchies with modular, has-a relationships.

First seen Apr 19, 2026

Installation

$ npx skills add muharremtozan/unity-agent-skills --skill unity-composition-pattern

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from muharremtozan/unity-agent-skills · top by installs.

npx skills add muharremtozan/unity-agent-skills

Browse all from muharremtozan/unity-agent-skills

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Repository health

Stars 13
Default branch main
Open issues 0
Status Active

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 1,705 B
  • docs SUMMARY.md 187 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 45 installs

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

1. Identify "Is-A" vs "Has-A"

  • Bad: ElectricCar : Car : Vehicle (Inheritance)
  • Good: Vehicle has an EngineConfig (Composition)

2. Multi-Value Returns (Tuples)

Instead of internal state-tracking:

public (int gold, int weight) Gather() => (10, 5);
// Client destructures instantly:
var (g, w) = node.Gather();

3. Strategy via SO

Attach different EntityConfigSO assets to the same ModularEntity to change its identity in the Inspector.