Category : 03. Getting Started

Service Injection 101 Here is a quick showcase of how a service can be injected to a component: Service.cs: using Sisus.Init; using UnityEngine; [Service] class Service { public void Greet() => Debug.Log(“Hello, World!”); } Client.cs: using Sisus.Init; class Client : MonoBehaviour<Service> { protected override void Init(Service service) => service.Greet(); } Create script files from the ..

Read more

To add a component and initialize it with arguments, you can use the GameObject.AddComponent<TComponent, T…> extension methods found in the Sisus.Init namespace. These work very much like the built-in GameObject.AddComponent<T> methods, except you also specify the types of the Init arguments alongside the type of the added component as the generic argument of the method, ..

Read more

What Is Dependency Injection Creating new components using the base classes in Init(args) is very similar to how it would work normally in Unity. The key difference is how the component obtains references to other objects that it depends on (its dependencies). Instead of components retrieving their dependencies using GameObject.Find, FindObjectOfType, GetComponent, static singleton properties ..

Read more