Author : Timo Naskali

To fully grasp the advantages that Init(args) can unlock, it’s essential to first understand a key design principle in software engineering: inversion of control. In a nutshell, inversion of control means that instead of classes independently retrieving the objects they need, those objects are provided to them by other classes. This approach comes with several ..

Read more

When a component that derives from MonoBehaviour<T> and has the InitOnResetAttribute is first attached to a GameObject in the editor, or when the user hits the Reset button in the Inspector’s context menu, the arguments accepted by the component are automatically gathered and passed to its Init function. This auto-initialization behaviour only occurs in edit ..

Read more

The Any<TValue> type can be used to create serialized fields into which you can assign any objects of the given type using the Inspector. The value can be of any type which Unity can serialize, using [SerializeField] or [SerializeReference], including: Plain-old C# class UnityEngine.Object An interface type You’ll be able to select any assignable value ..

Read more

What Are Initializers? Attaching an initializer to a client component gives you the ability to customize all its Init arguments using the Inspector window – with a lot of enhancements over what’s possible using Unity’s serialized fields by default. While registering global and local services makes it convenient to deliver the same service object to ..

Read more

The InitArgs class is the bridge through which initialization arguments are passed from the classes that create instances to the objects that are being created (called clients). Note that in most cases you don’t need to use InitArgs directly; all of the various methods provided for initializing instances with arguments already handle this for you ..

Read more

Init(args) contains new generic versions of the ScriptableObject base class, extending it with the ability to specify upto six objects that the class depends on. For example the following GameEvent class depends on a string and a GameObject. public class GameEvent : ScriptableObject<string, GameObject> When you create a class that inherits from one of the ..

Read more

The project comes with a simple demo game showcasing many of the features offered by Init(args). It acts as an example of a very flexible and easily unit-testable architecture that can scale well to drive large projects as well. Installing Dependencies Before installing the demo game you must first install the Unity UI and Test ..

Read more

To reference code in Init(args) from your own code you need to create assembly definition assets in the roots of your script folders and add references to the assemblies containing the scripts you want to use. Init(args) contains three assemblies: InitArgs – The main assembly that contains most classes including MonoBehaviour<T…>. InitArgs.Services – This contains ..

Read more

You may want to check from time to time if Init(args) has new updates so you don’t miss out on new features and fixes. Updating To The Latest Version The process for updating Init(args) is very similar to installing it, and done using the Package Manager window inside of Unity. You can do so by ..

Read more

Init(args) can be installed using the Package Manager window inside Unity. You can do so by following these steps: Open the Package Manager window using the menu item Window > Package Management > Package Manager. Select the My Assets view. Search for Init(args) and select it. If you see a Download button, use it to download ..

Read more