README.md

May 1, 2026 · View on GitHub

Saneject logo

Unity Tests Release License: MIT

Dependency injection the Unity way.

Inject dependencies in the Unity Editor, not Play Mode, by writing them directly into serialized fields at edit-time using familiar DI APIs, so everything stays visible in the Inspector, including interfaces.

No runtime container. No startup cost. No hidden wiring. No weird lifecycles. Just simple, deterministic edit-time DI that works with Unity, not around it.

Mental model

  1. Mark your fields, properties and methods with [Inject].
  2. Create a Scope that binds dependencies for [Inject] members, and add it to a scene or prefab.
  3. Click Inject in the Unity Editor.
  4. Dependencies are injected into serialized fields.
  5. Start the game and enjoy fast startup with Unity’s normal lifecycle.

Slide overview

A quick visual tour of how Saneject works, how editor-time DI differs from runtime DI, its core features, benefits, APIs, and examples.

Open the full slide overview

Preview of the Saneject slide overview

Main features

FeatureDescription
Editor-time injectionResolve dependencies in the editor and store them as normal serialized references.
Inspector-visible wiringKeep dependencies, including interfaces, visible and editable in the Inspector instead of hiding them behind a runtime container.
Fluent binding APIDeclare bindings in Scope components with familiar DI-style syntax.
Serialized interfacesUse [SerializeInterface] for interface fields, arrays, and lists without wrapper classes.
Scene, prefab, and context awarenessControl what gets injected where and how cross-context resolution behaves.
Runtime proxy bridgingHandle references Unity cannot serialize directly across scene and prefab boundaries.
Low runtime overheadNo runtime container, no reflection-based startup pass, and no extra lifecycle layer.
Built-in toolingUse injection menus, batch injection, logging, validation, settings, analyzers, and more directly in the Unity Editor.

For more features, see Feature overview.

Try Saneject now

Add this URL to Unity Package Manager (Unity 2022.3.12 or newer):

https://github.com/alexanderlarsen/Saneject.git?path=UnityProject/Saneject/Assets/Plugins/Saneject

Or download the latest release and import it folder into your Unity project.

Then jump to Quick start.

Feedback appreciated

If you try Saneject and something works well, feels unclear, or seems broken, I would love to hear about it.

  • If you find a bug, please open an Issue.
  • If you want to share feedback, ideas, or first impressions, drop a note in Discussions.