Author : Timo Naskali

The generic GameObject structs are builder that can be used to initialize a GameObject and upto three components in a single line of code. If you want a GameObject with a single component to be build, initialize a new instance of the GameObject<T> struct and specify the type of the component you want attached to ..

Read more

The Find class is a utility class that helps in locating instances of objects from loaded scenes as well as assets from the project. It has been designed from the ground up to work well with interface types, making it easier to decouple your code from specific concrete classes. All methods in the Find class ..

Read more

The ScriptableWrapper class is a ScriptableObject that can act as a simple wrapper for a plain old class object. It makes it easy to take a plain old class object and serialize it as an asset in the project. Let’s say you had a plain old class called Settings: public class Settings { public float ..

Read more

The Wrapper class is a component that acts as a simple wrapper for a plain old C# object. It makes it easy to take a plain old C# object and attach it to a GameObject and have it receive callbacks during any Unity events you care about such as Update or OnDestroy as well as ..

Read more

To fully understand what benefits Init(args) can unlock, one needs to first understand a key principle in software engineering: inversion of control. What inversion of control means in a nutshell is that instead of classes independently retrieving specific objects to work with, they will work with what ever objects are provided for them by other ..

Read more

When a component that derives from MonoBehaviour<T> and has the InitOnResetAttribute is first added 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<T> struct is similar to the Initializer class, but instead of it allowing you to specify all the Init arguments for a client, the Any<T> struct lets you specify just one argument. For example, if you wanted to make it possible to assign any class that implements the IPlayer interface using the inspector, you ..

Read more

A major benefit of injecting dependencies to your classes through the Init method is that it makes it easy to decouple your components from specific implementations when you use interfaces instead of specific classes as your argument types. The list of arguments that the Init method accepts also makes it very clear what other objects ..

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 five 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