What problem does it solve?
This Skill addresses the common challenge of structuring Unity code to be scalable, maintainable, and flexible, moving away from problematic deep inheritance hierarchies towards robust component-based design.
Core Features & Use Cases
- Composition Over Inheritance: Demonstrates how to break down behaviors into independent components that can be mixed and matched on GameObjects.
- Interface-Based Design: Explains how to use interfaces for loose coupling and defining contracts between components.
- Component Communication: Covers various patterns like direct references, events, ScriptableObject event channels, and init method injection.
- Dependency Injection: Introduces DI frameworks like VContainer for managing complex dependencies.
- Prefab Strategies: Discusses nested prefabs and prefab variants for efficient asset management.
- Use Case: You're building an enemy system. Instead of creating
FlyingEnemy inheriting from Enemy inheriting from Character, you'd compose Health, Mover, and Flyer components onto a base enemy GameObject.
Quick Start
Show me an example of using composition to create a flying enemy with health and a ranged attack.