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 | |
virtual void | Start () |
virtual void | OnConversationStart (Transform actor) |
virtual void | OnConversationEnd (Transform actor) |
virtual void | UseCurrentSelection () |
Calls OnUse on the current selection. | |
virtual void | RemoveGameObjectFromDetectedList (GameObject other) |
virtual void | RemoveUsableFromDetectedList (Usable usable) |
virtual void | SetCurrentUsable (Usable usable) |
virtual void | OnGUI () |
If useDefaultGUI is true and a usable object has been targeted, this method draws a selection message and targeting reticle. | |
Public Attributes | |
bool | useDefaultGUI = true |
If true , uses a default OnGUI to display a selection message and targeting reticle. | |
GUISkin | guiSkin |
The GUI skin to use for the target's information (name and use message). | |
string | guiStyleName = "label" |
The name of the GUI style in the skin. | |
TextAnchor | alignment = TextAnchor.UpperCenter |
The text alignment. | |
Color | color = Color.yellow |
The color of the information labels when the target is in range. | |
TextStyle | textStyle = TextStyle.Shadow |
The text style for the text. | |
Color | textStyleColor = Color.black |
The color of the text style's outline or shadow. | |
string | defaultUseMessage = "(spacebar to interact)" |
The default use message. | |
KeyCode | useKey = KeyCode.Space |
The key that sends an OnUse message. | |
string | useButton = "Fire2" |
The button that sends an OnUse message. | |
bool | enableTouch = false |
Tick to enable touch triggering. | |
ScaledRect | touchArea = new ScaledRect(ScaledRect.empty) |
If touch triggering is enabled and there's a touch in this area, the selector triggers. | |
bool | broadcastToChildren = true |
If ticked, the OnUse message is broadcast to the usable object's children. | |
Transform | actorTransform = null |
The actor transform to send with OnUse. | |
UsableUnityEvent | onSelectedUsable = new UsableUnityEvent() |
UsableUnityEvent | onDeselectedUsable = new UsableUnityEvent() |
List< Usable > | usablesInRange = new List<Usable>() |
Keeps track of which usable objects' triggers the selector is currently inside. | |
Protected Member Functions | |
virtual void | Reset () |
virtual void | OnEnable () |
virtual void | OnDisable () |
virtual void | Update () |
Sends an OnUse message to the current selection if the player presses the use button. | |
void | OnSelectedUsableObject (Usable usable) |
void | OnDeselectedUsableObject (Usable usable) |
virtual bool | IsUseButtonDown () |
Checks whether the player has just pressed the use button. | |
bool | IsTouchDown () |
void | OnTriggerEnter (Collider other) |
If we entered a trigger, check if it's a usable object. | |
void | OnTriggerExit (Collider other) |
If we just left a trigger, check if it's the current selection. | |
void | OnTriggerEnter2D (Collider2D other) |
If we entered a 2D trigger, check if it's a usable object. | |
void | OnTriggerExit2D (Collider2D other) |
If we just left a 2D trigger, check if it's the current selection. | |
virtual void | CheckTriggerEnter (GameObject other) |
virtual void | CheckTriggerExit (GameObject other) |
virtual void | OnUsableDisabled (Usable usable) |
void | SetGuiStyle () |
Protected Attributes | |
Usable | currentUsable = null |
The current usable that will receive an OnUse message if the player hits the use button. | |
string | currentHeading = string.Empty |
string | currentUseMessage = string.Empty |
bool | toldListenersHaveUsable = false |
GUIStyle | guiStyle = null |
Caches the GUI style to use when displaying the selection message in OnGUI. | |
float | guiStyleLineHeight = 16f |
float | timeToEnableUseButton = 0 |
Static Protected Attributes | |
const float | MinTimeBetweenUseButton = 0.5f |
Properties | |
Usable | CurrentUsable [get, set] |
Gets the current usable. | |
GUIStyle | GuiStyle [get] |
Gets the GUI style. | |
Events | |
SelectedUsableObjectDelegate | SelectedUsableObject = null |
Occurs when the selector has targeted a usable object. | |
DeselectedUsableObjectDelegate | DeselectedUsableObject = null |
Occurs when the selector has untargeted a usable object. | |
System.Action | Enabled = null |
System.Action | Disabled = null |
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 and Enabled and Disabled when the component is enabled or disabled.
|
inlineprotectedvirtual |
|
inlineprotectedvirtual |
|
inlineprotected |
|
inlineprotectedvirtual |
Checks whether the player has just pressed the use button.
true
if the use button/key is down; otherwise, false
.
|
inlinevirtual |
|
inlinevirtual |
|
inlineprotected |
|
inlineprotectedvirtual |
|
inlineprotectedvirtual |
|
inlinevirtual |
If useDefaultGUI is true
and a usable object has been targeted, this method draws a selection message and targeting reticle.
|
inlineprotected |
|
inlineprotected |
If we entered a trigger, check if it's a usable object.
If so, update the selection and raise the SelectedUsableObject event.
other | The trigger collider. |
|
inlineprotected |
If we entered a 2D trigger, check if it's a usable object.
If so, update the selection and raise the SelectedUsableObject event.
other | The 2D trigger collider. |
|
inlineprotected |
If we just left a trigger, check if it's the current selection.
If so, clear the selection and raise the DeselectedUsableObject event. If we're still in range of any other usables, select one of them.
other | The trigger collider. |
|
inlineprotected |
If we just left a 2D trigger, check if it's the current selection.
If so, clear the selection and raise the DeselectedUsableObject event. If we're still in range of any other usables, select one of them.
other | The 2D trigger collider. |
|
inlineprotectedvirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlineprotectedvirtual |
|
inlinevirtual |
|
inlineprotected |
|
inlinevirtual |
|
inlineprotectedvirtual |
Sends an OnUse message to the current selection if the player presses the use button.
|
inlinevirtual |
Calls OnUse on the current selection.
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.
|
protected |
|
protected |
The current usable that will receive an OnUse message if the player hits the use button.
|
protected |
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).
|
protected |
Caches the GUI style to use when displaying the selection message in OnGUI.
|
protected |
string PixelCrushers.DialogueSystem.ProximitySelector.guiStyleName = "label" |
The name of the GUI style in the skin.
|
staticprotected |
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.
|
protected |
|
protected |
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.
Keeps track of which usable objects' triggers the selector is currently inside.
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.
|
getset |
Gets the current usable.
The usable.
|
get |
Gets the GUI style.
The GUI style.
DeselectedUsableObjectDelegate PixelCrushers.DialogueSystem.ProximitySelector.DeselectedUsableObject = null |
Occurs when the selector has untargeted a usable object.
System.Action PixelCrushers.DialogueSystem.ProximitySelector.Disabled = null |
System.Action PixelCrushers.DialogueSystem.ProximitySelector.Enabled = null |
SelectedUsableObjectDelegate PixelCrushers.DialogueSystem.ProximitySelector.SelectedUsableObject = null |
Occurs when the selector has targeted a usable object.