Init(args)
Scripting Reference
Loading...
Searching...
No Matches
Sisus.Init.InitInEditModeAttribute Class Reference

Description

Add this attribute to classes to have them be initialized in Edit Mode whenever any objects in the same scene or prefab are modified.

This attribute can be added to any components that implement IInitializable, which includes all classes that derive from MonoBehaviour<>. When this is done, dependencies for the component are automatically retrieved from the scene hierarchy, relative to the GameObject that contains the component with the attribute. You can specify From where Object arguments should be searched, or use the default search mode, which tries to pick a good search mode to use based on the type of the argument:

The found arguments are passed to the component's IInitializable<>.Init function, where they can be assigned to serialized fields.

This behaviour only occurs in edit mode and is meant to make it more convenient to add components without needing to assign all Object references manually using the inspector.

This attribute can also be added to classes that derive from one of the Initializer<,> base classes. In this case, by default, the Init arguments will be taken from the initializer and passed to the client's Init function. If you specify From where arguments should be retrieved from, using values other than From.Initializer or From.Default, then said arguments will be located from the scene and assigned to the initializer first, and then also passed to the client's Init function.

If this attribute is present on both an initializer, as well as the client of the initializer, then the one found on the client class will be ignored, and the one found on the initializer will be in effect. This makes it possible to configure different options for the client when it has no initializers, and when it has different initializers attached to it.

See also
InitOnResetAttribute
Inheritance diagram for Sisus.Init.InitInEditModeAttribute:
Sisus.Init.InitOnResetAttribute

Public Member Functions

 InitInEditModeAttribute ()
 When this attribute is attached to a MonoBehaviour<> class, instances of the component are re-initialized whenever any objects in the same scene or prefab are modified.
 
 InitInEditModeAttribute (From search)
 When a component that derives from MonoBehaviour<> and has the InitInEditModeAttribute 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 IInitializable<>.Init function.
 
 InitInEditModeAttribute (From first, From second, From third=defaultFrom, From fourth=defaultFrom, From fifth=defaultFrom, From sixth=defaultFrom)
 When a component that derives from MonoBehaviour<> and has the InitInEditModeAttribute 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 IInitializable<>.Init function.
 
- Public Member Functions inherited from Sisus.Init.InitOnResetAttribute
 InitOnResetAttribute ()
 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 IInitializable<T>.Init function.
 
 InitOnResetAttribute (From search)
 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 IInitializable<T>.Init function.
 
 InitOnResetAttribute (From first, From second, From third=defaultFrom, From fourth=defaultFrom, From fifth=defaultFrom, From sixth=defaultFrom)
 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 IInitializable<T>.Init function.
 

Additional Inherited Members

- Public Attributes inherited from Sisus.Init.InitOnResetAttribute
readonly From first
 Defines where to search when trying to retrieve the first dependency of the attribute holder.
 
readonly From second
 Defines where to search when trying to retrieve the second dependency of the attribute holder.
 
readonly From third
 Defines where to search when trying to retrieve the third dependency of the attribute holder.
 
readonly From fourth
 Defines where to search when trying to retrieve the fourth dependency of the attribute holder.
 
readonly From fifth
 Defines where to search when trying to retrieve the fifth dependency of the attribute holder.
 
readonly From sixth
 Defines where to search when trying to retrieve the sixth dependency of the attribute holder.