HeadlinesBriefing favicon HeadlinesBriefing.com

Jeringa: Lightweight Unity DI with Custom Attributes

DEV Community •
×

Jeringa offers a lightweight Dependency Injection framework for Unity, letting developers attach custom attributes like [FromSelf] and [FromAny] to fields. Instead of dragging components into the inspector or calling GetComponent manually, the system automatically resolves dependencies at runtime, streamlining setup for small to medium projects.

Under the hood, Jeringa leverages C# Attributes and Reflection. Each attribute inherits from an abstract InjectAttribute that implements an Inject method. During Awake, the static Injector.Inject scans the target MonoBehaviour, finds annotated fields, and assigns the appropriate component or object found via GetComponent or FindAnyObjectByType.

Because the framework only targets MonoBehaviour and component dependencies, it stays lightweight compared to full‑blown solutions like Zenject. Developers can drop the Asset Store package or clone the GitHub repo, add attributes to their scripts, and enjoy automatic wiring without extra configuration or boilerplate code.

Jeringa’s design invites extensions—array handling, custom search scopes, or integration with Unity’s DOTS pipeline. As the community shares patterns on GitHub, expect more attribute types and tooling support. For teams looking to keep projects lean while still benefiting from DI, Jeringa offers a pragmatic, plug‑and‑play alternative.