
Develop faster with a simple, easy-to-use dependency injection framework for Unity.What SInject Brings to Your Unity ProjectsSInject provides a clean and straightforward approach to managing dependencies in Unity, helping you organize your code with clear separation of concerns. Its architecture around injectors and services lets you easily inject and resolve dependencies for scenes, prefabs, components, and scriptable objects.Why Choose SInject?Managing dependencies manually can lead to tightly coupled code and maintenance challenges. SInject helps you avoid these pitfalls by promoting modular design and enabling easier testing and refactoring. Its integration with Unity’s ecosystem means you can adopt dependency injection without interrupting your existing workflows.Simplified Dependency ManagementWith SInject, you set up a root injector and register your services effortlessly, whether they’re MonoBehaviours, ScriptableObjects, or .NET classes. Inject dependencies automatically at runtime with intuitive attributes, making your components lean and focused on their core responsibilities.Key CapabilitiesSupport for dependency injection in both scenes and gameObjectsPersistent services across scenes with configurable lifecycleInjection of components, scriptable objects, and plain .NET classesHandling of circular dependencies and collections of servicesPrefab spawning with automatic dependency injectionCustom injection support for advanced scenariosBuilt-in testing helpers to improve code qualityContext Debugger for runtime inspection of injection stateBoost Your Development WorkflowBy automating and standardizing how dependencies are injected, SInject helps you build more maintainable and testable Unity projects, saving time and reducing complexity during development and iteration.Core Injection SystemRoot Injector: Central singleton injector to register services and manage dependency resolution across your game.Scene Injection: Automatically injects dependencies when scenes load, cleaning up after injection.GameObject Injection: Injects dependencies on prefabs and supports creating local injectors for isolated scopes.Supported Service TypesComponents (MonoBehaviour)Scriptable Objects (marked with [SRegister])Plain .NET objectsCollections of services (T[], List, IEnumerable)Circular dependencies supported without issuesInjection Attributes[SInject]: Injects registered services into fields.[CInject]: Injects components from the same GameObject without requiring registration.[SRegister]: Marks ScriptableObjects or Components as injectable services.Service Registration & LifecycleRegister singleton services via the Root Injector’s asset list.Supports persistent services that survive across scene loads.Custom registration and injection logic via ISInjectorRegisterHandler and ISInjectorInjectHandlerinterfaces.Services can be added or removed dynamically, and the framework automatically unregisters Unity objects when they are destroyed.Prefab and Scene SupportPrefabs can have GameObjectInject to trigger injection at spawn.Local injectors for prefab-specific dependency scopes.Scene injectors to inject entire scenes on load.Advanced FeaturesDirect resolution API (Resolve(), TryResolve, resolving collections).Support for multiple instances of the same service type, with priority ordering.Context Debugger window to inspect active injectors and their registered services at runtime.Testing FrameworkUtilities for unit testing DI-dependent components using mock services.Enables writing more modular, testable game code by reducing reliance on scene-driven object references.Performance NotesReflection-heavy implementation; injection occurs mostly during scene load or prefab spawn.Designed for clarity and usability rather than extreme runtime performance.