Simple Dependency Injection's icon

Simple Dependency Injection 1.0.2 Tools 4.4 Community

Submitted by user comfygrapes; MIT; 2025-05-08

Easily add Dependency Injection into your project.

When the plugin is enabled, it will automatically create the necessary nodes in your current scene (preferably your Main). Simply add your node dependencies to the array in the [DependencyRegistrar] node and the [DependencyProvider] node will do the rest!

To allow dependency injection to happen in any script attached to a node in the scene tree, simply create either an _inject function or a _post_inject function, or both! But do keep in mind that these are only called after _ready.

This tool is useful in cases where:
1. You do not have direct access (via @export) to the nodes you need in a script and do not wish to create a global singleton via autoload.
2. You want a form of dependency inversion and wish to rely on abstractions to interact with other parts of your code.
3. The nodes you need have their own in-scene dependencies that they need to have direct access (via @export) to.


View files Download Submit an issue Recent Edits