Init(args)
Scripting Reference
List of all members | Public Member Functions | Public Attributes | Properties
Sisus.Init.EditorServiceAttribute Class Reference

Description

Classes that have the EditorServiceAttribute can provide services for one or more client objects in the editor in edit mode.

A single instance of each class that has the attribute will automatically get loaded behind the scenes making them ready for clients to retrieve as needed.

Objects deriving from MonoBehaviour<TDefiningClassOrInterface> or ScriptableObject<TDefiningClassOrInterface> receive the service during initialization automatically.

Other clients can retrieve a service by implementing the IArgs<TDefiningClassOrInterface> interface and calling InitArgs.TryGet<TClient, TDefiningClassOrInterface> during initialization.

It is possible to receive more than one services automatically by implementing an IArgs{} interface with more than one service argument (upto a maximum of five).

Services can also receive other services during initialization by implementing an IInitializable<TService> interface targeting the services they depend on.

Service<TDefiningClassOrInterface>.Instance can also be used to manually retrieve a service object.

Service objects that implement IAwake, IOnEnable or IStart receive the relevant event after all services have been created and all services have received the other services they depend on.

A service can optionally receive callbacks during select unity event functions by implementing one or more of the following interfaces:

Inherits Attribute.

Public Member Functions

 EditorServiceAttribute ()
 Classes that have the EditorServiceAttribute can provide services for one or more client objects. More...
 
 EditorServiceAttribute ([CanBeNull] Type definingType)
 Classes that have the EditorServiceAttribute can provide services for one or more client objects. More...
 

Public Attributes

readonly Type definingType
 Class or interface type that uniquely defines the service and can be used to retrieve an instance of the it. More...
 

Properties

string? AssetPath [get, set]
 Resources path from which an instance of the service can be loaded during initialization. More...
 
string? ResourcePath [get, set]
 Resources path from which an instance of the service can be loaded during initialization. More...
 
string? EditorDefaultResourcesPath [get, set]
 Editor Default Resources path from which an instance of the service can be loaded during initialization. More...