Component > Pixel Crushers > Dialogue System > Actor > Player > Selector
Selector provides an interface for the player to target Usable components and send OnUse messages to them.
Property | Function |
---|---|
Layer Mask | The layer mask to use when targeting objects. Objects on others layers are ignored. |
Select At | How to target (center of screen or under mouse cursor). Default is center of screen. |
Distance From | How to compute range to targeted object. Default is from the camera. |
Max Selection Distance | The max selection distance. The selector won't target objects farther than this. Usables also have their own Max Selection Distance. |
Run Raycasts | Specifies whether to run 2D or 3D raycasts. Note: In 2D mode, the camera must be orthographic. |
Raycast All | Tick to check all objects within the raycast range for usables. If unticked, the check stops on the first hit, even if it's not a usable. This prevents selection through walls. |
Use Default GUI | If ticked, use a default OnGUI to display a selection message and targeting reticle. |
Gui Skin | The GUI skin to use for the target's information (name and use message). |
Gui Style Name | The style in the GUI skin. Defaults to label. |
Alignment | The text alignment. |
Text Style | The text style for the name and use message. |
Text Style Color | The color of the text style's outline or shadow. |
In Range Color | The color of the information labels when the target is in range. |
Out Of Range Color | The color of the information labels when the target is out of range. |
Reticle | The targeting reticle images. |
Use Key | The key that sends an OnUse message. |
Use Button | The button that sends an OnUse message. |
Default Use Message | The default use message. This can be overridden in the target's Usable component. |
Broadcast To Children | If ticked, the OnUse message is broadcast to the usable object's children. |
Actor Transform | The actor from which this message is sent. If not set, defaults to the Selector's transform. |
Too Far Message | If not blank, this message is shown as an alert if the player tries to use a target that's too far. |
Debug | If ticked, draws raycast gizmos in the Scene view to show what the selector sees. |
The Selector finds targets by raycasting from a specified source such as the current mouse position or the center of the screen. If the raycast hits a collider that has a Usable component, the Selector displays a targeting message, and the player can press a button or key to send an OnUse message.
The GameObject with the Usable component must be able to be detected by a raycast, so it must have a collider and be on a layer specified in the Layer Mask property.
By default, the Selector uses legacy Unity GUI. To use Unity UI (including, optionally, TextMesh Pro), add a Selector Use Standard UI Elements component.
For more information, see Triggers & Interaction.
If you're making a 2D project in Unity 2018+, see Enable Physics2D Support.