API v1 checking… · p50 — · 0 installs/hr
v0.1.0
Project
View on GitHub
alexanderlarsen
New
79 0

Saneject provides dependency injection at edit-time in the Unity Editor, resolving dependencies directly into serialized fields rather than using runtime containers. Mark fields with [Inject], create a Scope component to bind dependencies, and click Inject to wire everything up. Dependencies remain visible and editable in the Inspector, including interfaces, with zero runtime overhead and no hidden startup costs.

Unity Project

Built with Unity 6000.0.59f2 · download the source from GitHub

Download 0

README

Rendered from 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

Feature Description
Editor-time injection Resolve dependencies in the editor and store them as normal serialized references.
Inspector-visible wiring Keep dependencies, including interfaces, visible and editable in the Inspector instead of hiding them behind a runtime container.
Fluent binding API Declare bindings in Scope components with familiar DI-style syntax.
Serialized interfaces Use [SerializeInterface] for interface fields, arrays, and lists without wrapper classes.
Scene, prefab, and context awareness Control what gets injected where and how cross-context resolution behaves.
Runtime proxy bridging Handle references Unity cannot serialize directly across scene and prefab boundaries.
Low runtime overhead No runtime container, no reflection-based startup pass, and no extra lifecycle layer.
Built-in tooling Use 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 the Saneject 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.

Links

Changelog 3 releases
  1. v0.8.3
    - Fixed bug where `SceneGlobalContainer` failed to unregister from `GlobalScope` on scene unload if the instance was null.
  2. v0.8.0
    Saneject is now confirmed to work from 2022.3.12f LTS.
  3. v0.7.1
    - Allow `[Inject]` attribute to be used with public fields without `[SerializeField]`.
    - Small refactor in the `Scope` binding API: `BindComponent<TComponent>()` and single generic variations are now `BindComponent<T>()`, to make it clearer that `T` can be both interface and concrete.

Comments

No comments yet. Be the first!