MuharremTozan/Agentic-Duel / .agent/skills/unity-dependency-injection
unity-dependency-injection
VerifiedImplements Dependency Inversion and Injection patterns. Decouples high-level logic from concrete implementations using attributes and reflection.
Unity Dependency Injection (DI)
A lightweight system to satisfy the "D" in SOLID. Allows classes to request dependencies via [Inject] without knowing who provides them.
Core Features
- Attribute-Based Injection: Use
[Inject]to mark fields and[Provide]to define sources. - Interface Focus: Encourages programming to abstractions, making systems hot-swappable.
- Automated Wiring: Scene-wide injection happens on Awake, ensuring dependencies are ready before Start.
- Diagnostic Logging: Tracks successful injections and warns about missing providers.
Core Files (Max 3)
DIAttributes.cs.txt: Contains the marker attributes for the compiler.DependencyInjector.cs.txt: The engine that finds and wires dependencies in the scene.DIExample.cs.txt: Shows how to decouple a Hero from an AbilitySystem.
Usage
1. Define an Interface
public interface IWeapon { void Fire(); }
2. Provide the Implementation
public class PlasmaRifle : MonoBehaviour, IWeapon {
[Provide] public IWeapon GetWeapon() => this;
public void Fire() { /* ... */ }
}
3. Inject into Client
public class Player : MonoBehaviour {
[Inject] private IWeapon currentWeapon;
void Start() => currentWeapon.Fire();
}
4. Setup
Place a DependencyInjector component in your scene or persistent prefab.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 193k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 193k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 193k | Updated | Claude CodeCodex | Verified | Install |