This component implements a proximity-based selector that allows the player to move into range and use a usable object. More...
Classes | |
class | Reticle |
This class defines the textures and size of the targeting reticle. More... | |
Public Member Functions | |
void | OnConversationEnd (Transform actor) |
void | UseCurrentSelection () |
virtual void | OnGUI () |
If useDefaultGUI is true and a usable object has been targeted, this method draws a selection message and targeting reticle. More... | |
Public Attributes | |
bool | useDefaultGUI = true |
If true , uses a default OnGUI to display a selection message and targeting reticle. More... | |
GUISkin | guiSkin |
The GUI skin to use for the target's information (name and use message). More... | |
string | guiStyleName = "label" |
The name of the GUI style in the skin. More... | |
TextAnchor | alignment = TextAnchor.UpperCenter |
The text alignment. More... | |
Color | color = Color.yellow |
The color of the information labels when the target is in range. More... | |
TextStyle | textStyle = TextStyle.Shadow |
The text style for the text. More... | |
Color | textStyleColor = Color.black |
The color of the text style's outline or shadow. More... | |
string | defaultUseMessage = "(spacebar to interact)" |
The default use message. More... | |
KeyCode | useKey = KeyCode.Space |
The key that sends an OnUse message. More... | |
string | useButton = "Fire2" |
The button that sends an OnUse message. More... | |
bool | enableTouch = false |
Tick to enable touch triggering. More... | |
ScaledRect | touchArea = new ScaledRect(ScaledRect.empty) |
If touch triggering is enabled and there's a touch in this area, the selector triggers. More... | |
bool | broadcastToChildren = true |
If ticked, the OnUse message is broadcast to the usable object's children. More... | |
Transform | actorTransform = null |
The actor transform to send with OnUse. More... | |
UsableUnityEvent | onSelectedUsable = new UsableUnityEvent() |
UsableUnityEvent | onDeselectedUsable = new UsableUnityEvent() |
Protected Member Functions | |
void | SetGuiStyle () |
Properties | |
Usable | CurrentUsable [get] |
Gets the current usable. More... | |
GUIStyle | GuiStyle [get] |
Gets the GUI style. More... | |
Events | |
SelectedUsableObjectDelegate | SelectedUsableObject = delegate { } |
Occurs when the selector has targeted a usable object. More... | |
DeselectedUsableObjectDelegate | DeselectedUsableObject = delegate { } |
Occurs when the selector has untargeted a usable object. More... | |
This component implements a proximity-based selector that allows the player to move into range and use a usable object.
To mark an object usable, add the Usable component and a collider to it. The object's layer should be in the layer mask specified on the Selector component.
The proximity selector tracks the most recent usable object whose trigger the player has entered. It displays a targeting reticle and information about the object. If the target is in range, the inRange reticle texture is displayed; otherwise the outOfRange texture is displayed.
If the player presses the use button (which defaults to spacebar and Fire2), the targeted object will receive an "OnUse" message.
You can hook into SelectedUsableObject and DeselectedUsableObject to get notifications when the current target has changed.
void PixelCrushers.DialogueSystem.ProximitySelector.OnConversationEnd | ( | Transform | actor | ) |
|
virtual |
If useDefaultGUI is true
and a usable object has been targeted, this method draws a selection message and targeting reticle.
|
protected |
void PixelCrushers.DialogueSystem.ProximitySelector.UseCurrentSelection | ( | ) |
Transform PixelCrushers.DialogueSystem.ProximitySelector.actorTransform = null |
The actor transform to send with OnUse.
Defaults to this transform.
TextAnchor PixelCrushers.DialogueSystem.ProximitySelector.alignment = TextAnchor.UpperCenter |
The text alignment.
bool PixelCrushers.DialogueSystem.ProximitySelector.broadcastToChildren = true |
If ticked, the OnUse message is broadcast to the usable object's children.
Color PixelCrushers.DialogueSystem.ProximitySelector.color = Color.yellow |
The color of the information labels when the target is in range.
string PixelCrushers.DialogueSystem.ProximitySelector.defaultUseMessage = "(spacebar to interact)" |
The default use message.
This can be overridden in the target's Usable component.
bool PixelCrushers.DialogueSystem.ProximitySelector.enableTouch = false |
Tick to enable touch triggering.
GUISkin PixelCrushers.DialogueSystem.ProximitySelector.guiSkin |
The GUI skin to use for the target's information (name and use message).
string PixelCrushers.DialogueSystem.ProximitySelector.guiStyleName = "label" |
The name of the GUI style in the skin.
UsableUnityEvent PixelCrushers.DialogueSystem.ProximitySelector.onDeselectedUsable = new UsableUnityEvent() |
UsableUnityEvent PixelCrushers.DialogueSystem.ProximitySelector.onSelectedUsable = new UsableUnityEvent() |
TextStyle PixelCrushers.DialogueSystem.ProximitySelector.textStyle = TextStyle.Shadow |
The text style for the text.
Color PixelCrushers.DialogueSystem.ProximitySelector.textStyleColor = Color.black |
The color of the text style's outline or shadow.
ScaledRect PixelCrushers.DialogueSystem.ProximitySelector.touchArea = new ScaledRect(ScaledRect.empty) |
If touch triggering is enabled and there's a touch in this area, the selector triggers.
string PixelCrushers.DialogueSystem.ProximitySelector.useButton = "Fire2" |
The button that sends an OnUse message.
bool PixelCrushers.DialogueSystem.ProximitySelector.useDefaultGUI = true |
If true
, uses a default OnGUI to display a selection message and targeting reticle.
KeyCode PixelCrushers.DialogueSystem.ProximitySelector.useKey = KeyCode.Space |
The key that sends an OnUse message.
|
get |
Gets the current usable.
The usable.
|
get |
Gets the GUI style.
The GUI style.
DeselectedUsableObjectDelegate PixelCrushers.DialogueSystem.ProximitySelector.DeselectedUsableObject = delegate { } |
Occurs when the selector has untargeted a usable object.
SelectedUsableObjectDelegate PixelCrushers.DialogueSystem.ProximitySelector.SelectedUsableObject = delegate { } |
Occurs when the selector has targeted a usable object.