PixelCrushers.DialogueSystem.ProximitySelector Class Reference

This component implements a proximity-based selector that allows the player to move into range and use a usable object. More...

Inheritance diagram for PixelCrushers.DialogueSystem.ProximitySelector:
Collaboration diagram for PixelCrushers.DialogueSystem.ProximitySelector:

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...
 

Detailed Description

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.

Member Function Documentation

◆ OnConversationEnd()

void PixelCrushers.DialogueSystem.ProximitySelector.OnConversationEnd ( Transform  actor)

◆ OnGUI()

virtual void PixelCrushers.DialogueSystem.ProximitySelector.OnGUI ( )
virtual

If useDefaultGUI is true and a usable object has been targeted, this method draws a selection message and targeting reticle.

◆ SetGuiStyle()

void PixelCrushers.DialogueSystem.ProximitySelector.SetGuiStyle ( )
protected

◆ UseCurrentSelection()

void PixelCrushers.DialogueSystem.ProximitySelector.UseCurrentSelection ( )

Member Data Documentation

◆ actorTransform

Transform PixelCrushers.DialogueSystem.ProximitySelector.actorTransform = null

The actor transform to send with OnUse.

Defaults to this transform.

◆ alignment

TextAnchor PixelCrushers.DialogueSystem.ProximitySelector.alignment = TextAnchor.UpperCenter

The text alignment.

◆ broadcastToChildren

bool PixelCrushers.DialogueSystem.ProximitySelector.broadcastToChildren = true

If ticked, the OnUse message is broadcast to the usable object's children.

◆ color

Color PixelCrushers.DialogueSystem.ProximitySelector.color = Color.yellow

The color of the information labels when the target is in range.

◆ defaultUseMessage

string PixelCrushers.DialogueSystem.ProximitySelector.defaultUseMessage = "(spacebar to interact)"

The default use message.

This can be overridden in the target's Usable component.

◆ enableTouch

bool PixelCrushers.DialogueSystem.ProximitySelector.enableTouch = false

Tick to enable touch triggering.

◆ guiSkin

GUISkin PixelCrushers.DialogueSystem.ProximitySelector.guiSkin

The GUI skin to use for the target's information (name and use message).

◆ guiStyleName

string PixelCrushers.DialogueSystem.ProximitySelector.guiStyleName = "label"

The name of the GUI style in the skin.

◆ onDeselectedUsable

UsableUnityEvent PixelCrushers.DialogueSystem.ProximitySelector.onDeselectedUsable = new UsableUnityEvent()

◆ onSelectedUsable

UsableUnityEvent PixelCrushers.DialogueSystem.ProximitySelector.onSelectedUsable = new UsableUnityEvent()

◆ textStyle

TextStyle PixelCrushers.DialogueSystem.ProximitySelector.textStyle = TextStyle.Shadow

The text style for the text.

◆ textStyleColor

Color PixelCrushers.DialogueSystem.ProximitySelector.textStyleColor = Color.black

The color of the text style's outline or shadow.

◆ touchArea

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.

◆ useButton

string PixelCrushers.DialogueSystem.ProximitySelector.useButton = "Fire2"

The button that sends an OnUse message.

◆ useDefaultGUI

bool PixelCrushers.DialogueSystem.ProximitySelector.useDefaultGUI = true

If true, uses a default OnGUI to display a selection message and targeting reticle.

◆ useKey

KeyCode PixelCrushers.DialogueSystem.ProximitySelector.useKey = KeyCode.Space

The key that sends an OnUse message.

Property Documentation

◆ CurrentUsable

Usable PixelCrushers.DialogueSystem.ProximitySelector.CurrentUsable
get

Gets the current usable.

The usable.

◆ GuiStyle

GUIStyle PixelCrushers.DialogueSystem.ProximitySelector.GuiStyle
get

Gets the GUI style.

The GUI style.

Event Documentation

◆ DeselectedUsableObject

DeselectedUsableObjectDelegate PixelCrushers.DialogueSystem.ProximitySelector.DeselectedUsableObject = delegate { }

Occurs when the selector has untargeted a usable object.

◆ SelectedUsableObject

SelectedUsableObjectDelegate PixelCrushers.DialogueSystem.ProximitySelector.SelectedUsableObject = delegate { }

Occurs when the selector has targeted a usable object.


The documentation for this class was generated from the following file: