About this project
VContainer is a high-performance Dependency Injection (DI) library designed specifically for Unity Game Engine. It emphasizes speed, minimal memory allocation, and small code size, making it an efficient alternative to other DI frameworks like Zenject.
Key features include:
- **Fast Resolve:** Typically 5-10x faster than Zenject.
- **Zero GC Allocation:** Resolving instances incurs no garbage collection overhead (excluding spawned instances).
- **Small Code Size:** Few internal types and minimal virtual calls.
- **Correct DI Practices:** Simple and transparent API with carefully selected features to avoid complexity.
- **Immutable Container:** Ensures thread safety and robustness.
Supported injection types: Constructor, Method, Property, and Field injection. It also provides flexible scoping with nested lifetime scopes, async support, and integration with UniTask and ECS (beta).
Installation is available via UPM (Git URL), OpenUPM, or manual .unitypackage. The library requires Unity 2018.4 or later.
Basic usage involves creating a LifetimeScope and registering services, then resolving them automatically. The library supports keyed bindings, entry points (IStartable, IAsyncStartable), and dynamic child scope creation for asynchronous resource loading.
A diagnostics window in the Unity Editor helps visualize and debug the container's registrations and dependencies.
VContainer is inspired by Zenject, Autofac, and MicroResolver, and is released under the MIT license.
Comments
0 Rating appears after 10 ratings
Sign in to join the discussion.