Category : 06. Initialization

Null Argument Guard The Null Argument Guard is a feature that can automatically inform you about missing Init arguments that any of your components might have. The feature consists of three distinct parts: Inspector Warnings – Warnings shown in the Editor when you view a component containing missing Init arguments in the Inspector Window. Edit ..

Read more

References to GameObjects and components that are only instantiated at runtime can be assigned into Init fields of client components that have an initializer. To assign a reference to an yet-to-be-instantiated prefab instance, drag-and-drop a prefab asset from the Project window into the Init field of a client component in a scene, and select ‘Prefab Instance’ ..

Read more

Cross-scene GameObject and component references can be assigned into Init fields of client components that have an initializer. To assign a cross-scene reference, open multiple scenes in the Editor, and drag-and-drop a GameObject from a different scene into the Init field of the client component. This will make Init(args) automatically generate a unique Cross-Scene Id ..

Read more

What is a Value Provider? Value providers are a highly flexible system that can be used to provide Init arguments dynamically at runtime. Value providers are any objects that implement IValueProvider<TValue> or IValueByTypeProvider (or their asynchronous counterparts, IValueProviderAsync<TValue> or IValueByTypeProviderAsync). Use Cases There are a lot of possible use cases for value providers – here ..

Read more

The [ValueProviderMenu] attribute can be used to introduce new menu items that will be shown in the dropdown menus for all Init arguments of targeted types. The attribute can be added to a ScriptableObject-derived class that implements IValueProvider<TValue> or IValueByTypeProvider. You can then use the Value property to access the value stored inside the field. ..

Read more

The generic GameObject structs are builders 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

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