3. Services Component

  5. Services No Comments

Services Component

Another way to define scene services is through using the Services component.

Start by adding the Services component to a GameObject in the scene and adding a new entry to its Provides Services list.

Then drag the component you want to define as a Service to this list.
If you drag a GameObject to the list a popup will open to allow you to specify which component from that GameObject you want to define as a service.

After you’ve dragged a component to the list, press the button that appears on the right side of the Object field to open the defining type dropdown menu. Select the defining type for the service from the menu.

You can define as many services as you want using a single Services component.

You can only drag-and-drop components and scriptable objects to the Services Component, not plain old C# objects. If you want to register a plain old C# object as a service using a Services component, you can create a wrapper or a value provider, and drag-and-drop that into the Services Component.

Leave a Reply

Your email address will not be published. Required fields are marked *