Argon-Runtime-Setup: Difference between revisions
No edit summary |
|||
| (4 intermediate revisions by the same user not shown) | |||
| Line 34: | Line 34: | ||
= Customizing Runtime Components = | = Customizing Runtime Components = | ||
To make customizing components easy, Argon | To make customizing components easy, Argon core components always talk to runtime components through interfaces. | ||
So, to replace an Argon runtime class, you just need to write your own implementation of the interface in question. | So, to replace an Argon runtime class, you just need to write your own implementation of the interface in question. | ||
| Line 40: | Line 40: | ||
For example: | For example: | ||
You want to replace the default | You want to replace the default highlight manager; (perhaps you want a version that plays an audio effect when an objects becomes highlighted, for example). | ||
The core code finds the highlight manager through | The core code finds the highlight manager through the '''SceneServices''' object. | ||
It asks SceneServices for its | It asks SceneServices for its ''OneAtATimeHighlightManager'' which is of type '''IOneAtATimeHighlightManager'''. | ||
To set up your custom highlight manager: | To set up your custom highlight manager: | ||
# Write a component that implements IOneAtATimeHighlightManager (defined in the namespace DuksGames.Argon.Adapters) | # Write a component that implements IOneAtATimeHighlightManager (defined in the namespace DuksGames.Argon.Adapters) | ||
# Add that component to an object in your scene | # Add that component to an object in your scene | ||
# Select the SceneServices object | # Select the SceneServices object in your scene (under DefaultPlayer). | ||
# In the SceneServices inspector, set the property 'One At A Time Highlight Manager' to the object that owns your custom component | # In the SceneServices inspector, set the property 'One At A Time Highlight Manager' to the object that owns your custom component | ||
# (Recommended) Remove the default Highlight Manager component since it is no longer in use. The component class name is ''HighlightManager'' and is attached to the SceneServices object. | |||
= Scene Services = | = Scene Services = | ||
The SceneServices object is an exchange point where the Argon core classes get the machinery they need to work at runtime. | The SceneServices object is an exchange point where the Argon core classes get the machinery they need to work at runtime. | ||
SceneServices exposes the following references: | |||
<pre> | <pre> | ||
Latest revision as of 07:29, 11 April 2024
Why is there a Runtime?
Argon adds components to your objects.
Some of these components need to run extra machinery in your scene to be useful.
For example, the Headline Display commands needs a mechanism for showing text on a UI document.
To get that mechanism, it asks an instance of SceneServices for an instance of IHeadlineDisplay.
So, you need:
- an instance of SceneServices in your scene
- an IHeadlineDisplay component to supply to SceneServices
Luckily, this is all set up for you already in the ARGON_DefaultPlayer.prefab. Just find it (under Assets >> Argon >> DefaultPlayer) and add it to your scene.
The DefaultPlayer prefab has an instance of SceneServices and an object with an IHeadlineDisplay component (named HeadlineFeedback).
In general, the DefaultPlayer prefab has all of the components you need to make all of your Argon components work.
When do I not need the Runtime?
You do not need the runtime if you are only adding standard Unity components--like Rigidbody, Box Collider, etc--with Argon.
You also don't need the runtime to set Layer, Static Flags and Tags on objects with Argon.
Why do I want customize the Runtime?
The runtime setup that comes packaged in the DefaultPlayer prefab has a player attached to a first person camera rig.
If you are making a first person game and are happy with the default implementations supplied with Argon, then you're all set.
But you'll likely want to change at least a few things to suit the needs of your game.
And in many scenarios this will mean that you'll want to supply your own classes and components to Argon to replace the equivalent default classes and components.
Customizing Runtime Components
To make customizing components easy, Argon core components always talk to runtime components through interfaces.
So, to replace an Argon runtime class, you just need to write your own implementation of the interface in question.
For example:
You want to replace the default highlight manager; (perhaps you want a version that plays an audio effect when an objects becomes highlighted, for example).
The core code finds the highlight manager through the SceneServices object.
It asks SceneServices for its OneAtATimeHighlightManager which is of type IOneAtATimeHighlightManager.
To set up your custom highlight manager:
- Write a component that implements IOneAtATimeHighlightManager (defined in the namespace DuksGames.Argon.Adapters)
- Add that component to an object in your scene
- Select the SceneServices object in your scene (under DefaultPlayer).
- In the SceneServices inspector, set the property 'One At A Time Highlight Manager' to the object that owns your custom component
- (Recommended) Remove the default Highlight Manager component since it is no longer in use. The component class name is HighlightManager and is attached to the SceneServices object.
Scene Services
The SceneServices object is an exchange point where the Argon core classes get the machinery they need to work at runtime.
SceneServices exposes the following references:
public ICursorLocker CursorLocker
public ICamSwap CamSwap
public IPlayerProvider PlayerProvider
public IOneAtATimeHighlightManager OneAtATimeHighlightManager
public ICamLockSessionOneAtATimeHighlightManager CamLockSessionOneAtATimeHighlightManager
public IHeadlineDisplay HeadlineDisplay
public IUpdateStack PlayerUpdateStack
public IThirdPersonControllerStateManager ThirdPersonControllerStateManager
public IProximityClickManager ProximityClickManager
public ICurrentBeaconProvider CurrentBeaconProvider
All of the default implementations of these interfaces are included in Argon's source code.