Home

Awesome

[DependencyAttributes] Atreebooster DI

The Hierarchy-based Dependency Injection tool.
Intuitivly manage dependencies of your MonoBehaviours with simple but powerfull [Attributes]:

Named parameters:

It works with multiple scenes loaded and DDOL objects.
It also provides MonoBehaviourSingleton allowing you to access the script from anywhere like this: SoundManager.Instance; or [GlobalComponent] SoundManager soundManager;

[ReferenceComponent] example and discussion about the tool

Usage

Copy MonoBehaviourExtended.cs and MonoBehaviourSingleton.cs to your project from https://github.com/kubpica/AtreeboosterDI/tree/master/Assets/AtreeboosterDI

Derive from MonoBehaviourExtended instead of MonoBehaviour. It provides the hierarchy based dependency injection attributes.
If you want to use Awake() in your script, hide the method (with the 'new' keyword) and call base.Awake();

If you want your script to be Singleton derive from MonoBehaviourSingleton<T> like this:

public class SoundManager : MonoBehaviourSingleton<SoundManager> {}  

Place it anywhere in the scene and then you can access it from any script like this: SoundManager.Instance; or [GlobalComponent] SoundManager soundManager;

Known issues and tips

Licence

MIT but credit or review on Unity Asset Store would be nice ;)

Do you like my work? Check my games on Steam! https://store.steampowered.com/search/?developer=Polish%20Hacker

Unity Asset Store version

https://assetstore.unity.com/packages/tools/integration/dependencyattributes-atreebooster-di-157631