unity-dependency-injection

Enable dependency injection in Unity via [Inject] and [Provide] attributes.

Updated Feb 13, 2026
One-click install
npx skills add https://github.com/MuharremTozan/Ohm-Yura --skill unity-dependency-injection
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: unity-dependency-injection
Source: https://github.com/MuharremTozan/Ohm-Yura/tree/main/.agents/skills/unity-dependency-injection
Command: npx skills add https://github.com/MuharremTozan/Ohm-Yura --skill unity-dependency-injection

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes assets (resource) components.

What problem does it solve?

Dependency injection reduces tight coupling by letting components request dependencies without hard references to concrete implementations.

Core Features & Use Cases

  • Attribute-Based Injection: Use [Inject] to declare dependencies and [Provide] to expose providers.
  • Automated Wiring: Dependencies are wired in Awake, ensuring availability before Start.
  • Diagnostics: Logs successful injections and reports missing providers.

Quick Start

Attach a DependencyInjector to a scene, and annotate fields with [Inject] while exposing providers using [Provide].

Frequently Asked Questions about unity-dependency-injection

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I decouple MonoBehaviour logic using dependency injection in Unity?

Dependency injection in Unity decouples logic by letting MonoBehaviours request interfaces through [Inject] attributes and receive concrete implementations via [Provide] attributes. This enables swappable components across scenes without hard references.

When does dependency injection wiring occur in the Unity lifecycle?

Dependency injection wiring occurs during the Awake phase, ensuring all requested dependencies are fully resolved and available before Start runs. This guarantees providers are ready for immediate use in your Unity components.

Can I use attribute-based dependency injection for C# game development?

Attribute-based dependency injection supports C# game development by annotating fields with [Inject] to declare dependencies and using [Provide] to expose implementations. A DependencyInjector resolves these providers across scenes.

How do I debug missing providers in Unity dependency injection?

Debugging missing providers relies on built-in diagnostic logging that reports missing implementations and logs successful injections. This immediately highlights incomplete wiring during the Awake initialization phase.

What is the best way to set up a DependencyInjector in Unity?

The best way to set up a DependencyInjector is to attach a DependencyInjector object to a scene, annotate fields with [Inject], and expose providers using [Provide] to automate component wiring.

Does Unity dependency injection support swappable components across scenes?

Unity dependency injection supports swappable components across scenes by decoupling high-level logic from concrete providers. Interfaces requested via [Inject] receive implementations through [Provide], allowing flexible scene transitions.