{"id":13676440,"url":"https://github.com/kubpica/AtreeboosterDI","last_synced_at":"2025-04-29T07:32:16.837Z","repository":{"id":65693027,"uuid":"221775186","full_name":"kubpica/AtreeboosterDI","owner":"kubpica","description":"The Hierarchy-based Dependency Injection tool for Unity game engine. Intuitivly manage dependencies of your MonoBehaviours with simple but powerfull [Attributes]","archived":false,"fork":false,"pushed_at":"2024-10-13T13:44:05.000Z","size":503,"stargazers_count":24,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-11T18:41:24.038Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kubpica.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-11-14T19:51:54.000Z","updated_at":"2024-10-31T14:46:12.000Z","dependencies_parsed_at":"2023-02-15T23:46:17.431Z","dependency_job_id":null,"html_url":"https://github.com/kubpica/AtreeboosterDI","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kubpica%2FAtreeboosterDI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kubpica%2FAtreeboosterDI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kubpica%2FAtreeboosterDI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kubpica%2FAtreeboosterDI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kubpica","download_url":"https://codeload.github.com/kubpica/AtreeboosterDI/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251455925,"owners_count":21592263,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T13:00:27.069Z","updated_at":"2025-04-29T07:32:15.839Z","avatar_url":"https://github.com/kubpica.png","language":"C#","funding_links":[],"categories":["Open Source Repositories"],"sub_categories":["Dependency Injection"],"readme":"# [DependencyAttributes] Atreebooster DI\nThe Hierarchy-based Dependency Injection tool.  \nIntuitivly manage dependencies of your MonoBehaviours with simple but powerfull [Attributes]:  \n - [Component] - automatically finds the most likely component and injects the marked field with it.  \n - [GlobalComponent] - finds the singleton or traverses scene GameObjects looking for the component of the marked field type.  \n - [ChildComponent] - finds the component in children (descendants).  \n - [ParentComponent] - finds the component in parents (predecessors).  \n - [SiblingComponent] - finds the component in siblings.  \n - [FamilyComponent] - searches for the component starting from parent down along the hierarchy.  \n - [FamilyComponent(true)] - find the component in own tree (form root down along the hierarchy).  \n - [OwnComponent] - looks for the component only in itself (own GameObject).  \n - [ReferenceComponent] - looks for the component in GameObjects marked [ReferencePoint].  \n - [Child(name/index)] - Finds the GameObject by name in children (descendants) or gets one by index.  \n - [Parent(name/index)] - Finds the GameObject by name in parents (predecessors) or gets one by index.  \n - [Sibling(name/index)] - Finds the GameObject by name in siblings or gets one by index.  \n - [Reference(name)] - Finds closest in the hierarchy GameObject by name.  \n - [Root] - Gets own root GameObject or finds one by name if specified.  \n  \nNamed parameters:  \n - string Of - Name of a GameObject to find and apply the attribute's algorythm to. If there are multiple GameObjects with the same name, it finds the closest one in the hierarchy.  \n - int Offset - Offset in hierarchy from \"Of\" GameObject.  \n - bool Optional - If false, new component/gameobject is created when it's not found; otherwise just warning is displayed and dependency is not injected. (false by default)  \n - bool SkipItself - If true, own GameObject is skiped; otherwise included in search for the component. (false by default)\n  \nIt works with multiple scenes loaded and DDOL objects.  \nIt also provides MonoBehaviourSingleton allowing you to access the script from anywhere like this: SoundManager.Instance; or [GlobalComponent] SoundManager soundManager;\n\n[[ReferenceComponent] example and discussion about the tool](https://forum.unity.com/threads/dependencyattributes-atreebooster-di.974097/#post-8783116)\n\n# Usage\nCopy MonoBehaviourExtended.cs and MonoBehaviourSingleton.cs to your project from https://github.com/kubpica/AtreeboosterDI/tree/master/Assets/AtreeboosterDI\n\nDerive from MonoBehaviourExtended instead of MonoBehaviour. It provides the hierarchy based dependency injection attributes.  \nIf you want to use Awake() in your script, hide the method (with the 'new' keyword) and call base.Awake();  \n  \nIf you want your script to be Singleton derive from MonoBehaviourSingleton\u003cT\u003e like this:  \n ```c#\npublic class SoundManager : MonoBehaviourSingleton\u003cSoundManager\u003e {}  \n ```\nPlace it anywhere in the scene and then you can access it from any script like this: SoundManager.Instance; or [GlobalComponent] SoundManager soundManager;  \n\n# Known issues and tips\n - If you try to inject a GameObject (or Unity's built in component - non-MonoBehaviour) it should be private or marked with [NonSerialized], otherwise it may conflict with the Unity serializer and the dependency may not be injected. MonoBehaviours can be public.\n - Using the [Component] attribute is convenient but you will probably get better performance if you use the more specific ones. You still can use it, just be carefull in extreme cases.\n - If you want to use the [GlobalComponent] attribute with non-MonoBehaviourSingleton\u003cT\u003e components it's better to put them in one of the root gameobjects; otherwise it may be expensive.\n - It uses reflection and searches the hierarchy runtime which can be expensive, so using this in components that are frequently spawned during gameplay can be problematic.\n\n# Licence\nMIT but credit or review on Unity Asset Store would be nice ;)\n\nDo you like my work? Check my games on Steam! https://store.steampowered.com/search/?developer=Polish%20Hacker\n\n# Unity Asset Store version\nhttps://assetstore.unity.com/packages/tools/integration/dependencyattributes-atreebooster-di-157631\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkubpica%2FAtreeboosterDI","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkubpica%2FAtreeboosterDI","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkubpica%2FAtreeboosterDI/lists"}