vcontainer

Configure Unity dependency injection with hierarchical LifetimeScope composition.

Updated May 6, 2026
One-click install
npx skills add https://github.com/BasarEkinci/memory-card-game --skill vcontainer-basarekinci
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vcontainer
Source: https://github.com/BasarEkinci/memory-card-game/tree/main/.claude/skills/third-party/vcontainer
Command: npx skills add https://github.com/BasarEkinci/memory-card-game --skill vcontainer-basarekinci

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

VContainer solves brittle Unity coupling by providing a lightweight dependency injection approach that keeps components loosely connected and easier to test.

Core Features & Use Cases

  • Hierarchical scoping: Compose dependencies with a parent-child LifetimeScope structure so scene-specific services can override project-wide services safely.
  • Constructor + method injection: Use constructor injection for plain C# classes and [Inject] method injection for MonoBehaviour components to keep dependencies explicit.
  • Configurable composition: Register interfaces to implementations, register instances like ScriptableObject data, and create runtime objects via factories and entry points for consistent lifecycles.
  • Use Case: In a Unity game, register shared services (audio/save/analytics) at a root scope, register per-scene systems (score/spawn/UI) in scene scopes, and inject them into controllers without manual wiring across dozens of scripts.

Quick Start

Use the vcontainer skill to configure a RootLifetimeScope and a scene LifetimeScope, then register your services and controllers so dependencies are resolved automatically across scopes.

Frequently Asked Questions about vcontainer

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

FAQPage Schema
How do I use dependency injection in Unity without relying on singletons?

VContainer enables Unity dependency injection without singletons by using hierarchical LifetimeScope composition. You register explicit interface-to-implementation bindings and scoped resolutions, ensuring plain C# systems and MonoBehaviours receive dependencies automatically across parent-child scopes.

What is the difference between constructor injection and method injection for Unity MonoBehaviours?

The difference is that constructor injection applies to plain C# classes for explicit dependencies, while method injection using the [Inject] attribute applies to MonoBehaviour components. This distinction keeps dependencies explicit and makes components loosely connected and easier to test.

How do I configure scene-specific services to override project-wide services in Unity?

You configure scene-specific service overrides by composing dependencies with a parent-child LifetimeScope structure. Register project-wide services like audio and analytics at a root scope, then safely override them with scene-specific score or spawn systems in child scopes.

Can I register ScriptableObject instances and runtime factories for Unity dependency injection?

Yes, VContainer supports configurable composition allowing you to register existing instances like ScriptableObject data and create runtime objects via factories. This ensures consistent lifecycles and explicit registration of lifetimes across your Unity application architecture.

Does VContainer work with plain C# systems or does it require MonoBehaviour components?

VContainer works with both plain C# systems and MonoBehaviour components. It applies constructor injection for plain C# classes and method injection with lifecycle entry points for MonoBehaviour components, keeping dependencies explicit across your Unity architecture.

Why does my Unity game architecture have brittle coupling between components?

Brittle Unity coupling occurs when components are tightly connected without managed dependency injection. VContainer solves this by providing a lightweight approach using hierarchical LifetimeScope composition and explicit bindings, keeping components loosely connected and easier to test.