What problem does it solve?
VContainer provides a structured dependency injection (DI) approach for Unity projects, enabling explicit lifetimes, scopes, and testable code by centralizing object creation and resolution.
Core Features & Use Cases
- Lifetime management through Singleton, Scoped, and Transient patterns, with guidance on avoiding cross-scope leaks.
- Registration patterns including basic, instance, factory, and entry point registrations to compose decoupled systems.
- Injection patterns such as constructor, method, and (optionally) property injection to wire dependencies cleanly.
- Scoped containers and child scopes for feature isolation, with examples of installers and segment loading patterns.
- Common crash fixes and safe resolution practices, including TryResolve and scope-alive checks.
- Testing strategies with DI in Unity, including unit tests and installer validation.
- Editor cleanup considerations to prevent DI-related issues during Play mode.
Quick Start
Configure a LifetimeScope, register services with Singleton lifetimes, and resolve dependencies via constructors to begin using VContainer in Unity.