{"id":15160605,"url":"https://github.com/justinleemans/uni-injection","last_synced_at":"2025-04-05T19:15:49.045Z","repository":{"id":183505668,"uuid":"670272339","full_name":"justinleemans/uni-injection","owner":"justinleemans","description":"Lightweight experimental dependency injection framework for Unity","archived":false,"fork":false,"pushed_at":"2024-06-19T14:47:07.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-02-09T21:33:12.781Z","etag":null,"topics":["dependency","dependency-injection","dependency-manager","injection","package","unity","unity3d-plugin","upm","upm-package"],"latest_commit_sha":null,"homepage":"","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/justinleemans.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-24T17:11:20.000Z","updated_at":"2024-03-04T19:20:26.000Z","dependencies_parsed_at":"2024-02-16T20:30:55.084Z","dependency_job_id":"aaa8224b-90c1-4a7d-a59c-e317754ef356","html_url":"https://github.com/justinleemans/uni-injection","commit_stats":{"total_commits":13,"total_committers":2,"mean_commits":6.5,"dds":0.07692307692307687,"last_synced_commit":"fde35f06f2f4685918a04e58d9f1c7c09b2801be"},"previous_names":["justinleemans/just-inject","justinleemans/uni-injection"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinleemans%2Funi-injection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinleemans%2Funi-injection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinleemans%2Funi-injection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinleemans%2Funi-injection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/justinleemans","download_url":"https://codeload.github.com/justinleemans/uni-injection/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247386267,"owners_count":20930619,"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":["dependency","dependency-injection","dependency-manager","injection","package","unity","unity3d-plugin","upm","upm-package"],"created_at":"2024-09-26T23:03:37.732Z","updated_at":"2025-04-05T19:15:49.026Z","avatar_url":"https://github.com/justinleemans.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# UniInjection - Lightweight experimental dependency injection framework for Unity\n\nUniInjection is a lightweight experimental dependency injection framework. I started this project as a little side project and is currently in a mostly functional state. Feel free to try it out and experiment with it. If you have any suggestions or improvements dont't hesitate to contribute.\n\n# Table of Contents\n\n- [Installation](#installation)\n- [Quick Start](#quick-start)\n- [Contributing](#contributing)\n\n# Installation\n\nCurrently the best way to include this package in your project is through the unity package manager. Add the package using the git URL of this repo: https://github.com/justinleemans/uni-injection.git\n\n# Quick Start\n\n## Bootstrapper\n\nStart setting up your dependencies by first making a new class inheriting from `Bootstrapper.cs` with the type of the class you just created. Next include the required override `OnInstallBindings()`. This method is where you will define your bindings for this bootstrapper.\n\n```c#\npublic class ExampleBootstrapper : Bootstrapper\u003cExampleBootstrapper\u003e\n{\n\tprotected override void OnInstallBindings()\n\t{\n\t}\n}\n```\n\nAfter you created this class you can go to your scene and create a empty gameobject and at this script to it. You can choose to make this bootstrapper global or not. When made global this bootstrapper will act like a singleton and persist through scenes and will carry over it's configured dependencies.\n\nYou can choose to create one or multiple bootstrappers (global or not) for any purpose. You can choose to make a single global bootstrapper to carry dependencies for the entire project. You can choose to make bootstrappers for scenes to hold scene specific dependencies. And you can choose to make bootstrappers for specific systems if these systems are repeated in certain places in the project.\n\n## Binding\n\nAfter setting up a bootstrapper you can start adding dependencies. To simply add a dependency use the `ServiceContainer` within the `OnInstallBindings` method by calling `Bind\u003cT\u003e()`. This will create the most basic binding.\n\n```c#\nServiceContainer.Bind\u003cExampleService\u003e();\n```\n\nThis will assume that the type you bind will also be the type to inject to. If you want to choose to bind a specific class to it's interface('s) you can use the `Bind\u003cT\u003e()` method for the interface and add the `To\u003cT\u003e()` method to choose what type to use for this interface.\n\n```c#\nServiceContainer.Bind\u003cIExampleService\u003e().To\u003cExampleService\u003e();\n```\n\nIn case you want to bind a single class to multiple of it's own interfaces you can simply add more bindings.\n\n```c#\nServiceContainer.Bind\u003cIExampleService\u003e().To\u003cExampleService\u003e();\nServiceContainer.Bind\u003cISomeOtherInterface\u003e().To\u003cExampleService\u003e();\n```\n\nBy default the binding will assume it needs to create a new instance everytime a field of this type needs to be populated. If you want to explicitly show this in you bootstrapper you can add the method `FromNew()` to the end. If you want to use and already existing instance of this type than you can add `FromInstance(instance)` at the end.\n\n```c#\nServiceContainer.Bind\u003cExampleService\u003e().FromNew();\n...\nServiceContainer.Bind\u003cExampleService\u003e().FromInstance(instance);\n```\n\nFinally if you want the binding to be forced to use the same instance everytime you can choose to make your binding a singleton. Simply add `AsSingleton()` to the end of the binding.\n\n```c#a\nServiceContainer.Bind\u003cExampleService\u003e().AsSingleton();\n```\n\nNote: currently when creating a binding using `FromInstance(instance)` the binding will automatically be converted to a singleton. This behaviour might change in a later stage.\n\n# Contributing\n\nCurrently I have no set way for people to contribute to this project. If you have any suggestions regarding improving on this project you can make a ticket on the GitHub repository or contact me directly.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustinleemans%2Funi-injection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjustinleemans%2Funi-injection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustinleemans%2Funi-injection/lists"}