unity-coding-di

Register services and resolve dependencies in Unity C# with UniT.DI.

Updated Aug 20, 2025
One-click install
npx skills add https://github.com/frostbun/dotfiles --skill unity-coding-di
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: unity-coding-di
Source: https://github.com/frostbun/dotfiles/tree/main/configs/opencode/skills/unity/unity-coding-di
Command: npx skills add https://github.com/frostbun/dotfiles --skill unity-coding-di

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill simplifies the implementation of dependency injection (DI) in Unity C# projects, providing a robust framework for managing object lifecycles and dependencies.

Core Features & Use Cases

  • Dependency Injection: Implement manual and automatic registration of services and types.
  • Unity Resource Integration: Register dependencies from Resources, prefabs, and the scene hierarchy.
  • Container Support: Works with UniT.DI's default DependencyContainer and integrates with VContainer and Zenject.
  • Use Case: When setting up a new Unity project, use this skill to register your core services like IAudioManager and IInputService into the DI container, ensuring they are easily resolvable throughout your project.

Quick Start

Use the unity-coding-di skill to register the 'MyGameManager' class for the 'IGameManager' interface.

Frequently Asked Questions about unity-coding-di

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

FAQPage Schema
How do I set up dependency injection in Unity C# projects?

To set up dependency injection in Unity C#, use this Skill to register interfaces like IGameManager into a DI container. It handles service registration, dependency resolution, and object instantiation with constructor injection.

Can I use VContainer or Zenject with UniT.DI for dependency registration?

Yes, UniT.DI integrates with VContainer and Zenject DI containers. You can use this Skill to configure container support while registering services and resolving dependencies across your Unity project.

How do I register Unity resources and prefabs in a DI container?

You can register Unity resources by configuring dependencies from the Resources folder, prefabs, and scene hierarchy. This Skill facilitates auto-registration to ensure assets are resolvable through the IDependencyContainer interface.

What is the best way to resolve dependencies from Unity scene hierarchy?

The best way to resolve scene hierarchy dependencies is using the IDependencyContainer interface to register and instantiate objects. This Skill covers manual and auto-registration for resolving services directly from scenes.

Does constructor injection work with UniT.DI for instantiating game objects?

Yes, constructor injection works for instantiating objects in Unity. This Skill facilitates dependency injection by configuring the DependencyContainer to resolve and inject required services during object creation.

When do I need to use auto-registration for Unity dependency injection?

You need auto-registration when managing multiple services like IAudioManager and IInputService in a Unity project. This Skill streamlines dependency injection by automatically registering types into the DI container.