EasyTalk API
Loading...
Searching...
No Matches
EasyTalk.Display.DialogueButton Class Reference

This is an implementation of a button component used by the dialogue display system. More...

Inherits MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IPointerDownHandler, and IPointerUpHandler.

Public Member Functions

void OnPointerUp (PointerEventData eventData)
 Called when the mouse pointer is released over the button.
 
void OnPointerDown (PointerEventData eventData)
 Called when the mouse is pressed over the button.
 
void OnPointerEnter (PointerEventData eventData)
 Called when the mouse moves over the button.
 
void OnPointerExit (PointerEventData eventData)
 Called when the mouse leaves the button.
 
void PlayHoverSound ()
 Plays the hover sound set on the button.
 
void DisplayHighlighted ()
 Sets the button to display itself in highlighted mode.
 
void DisplayNormal ()
 Sets the button to display itself in normal mode.
 
void DisplayPressed ()
 Sets the button to display itself in pressed mode.
 
void DisplayDisabled ()
 Sets the button to display itself in disabled mode.
 
void SetText (string text)
 Sets the text of the button.
 

Public Attributes

Color normalTextColor = new Color(0.85f, 0.85f, 0.85f)
 The color of the text when the button is in 'normal' mode.
 
Color disabledTextColor = new Color(0.4f, 0.4f, 0.4f)
 The color of the text when the button is in 'disabled' mode.
 
Color highlightedTextColor = new Color(1.0f, 1.0f, 1.0f)
 The color of the text when the button is in 'highlighted' mode.
 
Color pressedTextColor = new Color(0.7f, 0.7f, 0.7f)
 The color of the text when the button is in 'pressed' mode.
 
Image backgroundImage
 The image used for the button.
 
Color normalButtonColor = new Color(0.3f, 0.3f, 0.3f)
 The color of the image when the button is in 'normal' mode.
 
Color disabledButtonColor = new Color(0.15f, 0.15f, 0.15f)
 The color of the image when the button is in 'disabled' mode.
 
Color highlightedButtonColor = new Color(0.5f, 0.5f, 0.5f)
 The color of the image when the button is in 'highlighted' mode.
 
Color pressedButtonColor = new Color(0.25f, 0.25f, 0.25f)
 The color of the image when the button is in 'pressed' mode.
 
AudioClip hoverSound
 The sound to play when the player hovers over the button.
 
UnityEvent onClick = new UnityEvent()
 A Unity Event that gets triggered when the button is clicked.
 
UnityEvent onEnter = new UnityEvent()
 A Unity Event that gets triggered when the button is entered by the mouse.
 
UnityEvent onLeave = new UnityEvent()
 A Unity Event that gets triggered when the button is left by the mouse.
 
UnityEvent onPress = new UnityEvent()
 A Unity Event that gets triggered when the button is pressed down.
 
UnityEvent onHighlighted = new UnityEvent()
 A Unity Event that gets triggered when the button goes into 'highlighted' mode.
 
UnityEvent onNormal = new UnityEvent()
 A Unity Event that gets triggered when the button goes into 'normal' mode.
 

Properties

bool Interactable [get, set]
 A flag which controls whether the button is interactable.
 
bool IsClickable [get, set]
 Whether the button is clickable. Returns false if the button is disabled. Setting this value to true will change the button to display in normal mode, and setting it to false will set it to display in disabled mode.
 
object Value [get, set]
 Gets or sets the value attributed to the button.
 
Text StandardText [get, set]
 Gets or sets the standard Unity Text component of the button.
 

Private Member Functions

void Awake ()
 Sets up various callbacks for mouse interactions.
 
IEnumerator PlaySoundAsync (AudioSource source, AudioClip clip)
 Plays the provided sound asynchronously and removes the audio source from the on demand queue once the sound is finished playing.
 
void OnDisable ()
 Removes all leftover on-demand audio sources from the button.
 

Private Attributes

Text text
 The text element of the button.
 
AudioSource audioSource
 The audio source used by the button.
 
bool isClickable = true
 Whether the button is clickable.
 
bool isClickReady = false
 A flag indicating whether the button is ready for a click to be completed (set to true when the button is pressed and the mouse is in the button's area).
 
object value
 A value attributed to the button.
 
List< AudioSource > onDemandAudioSources = new List<AudioSource>()
 A collection of temporary audio sources used to queue up sounds to prevent hard cutoffs.
 
int maxAudioSources = 4
 The maximum number of audio sources the button is allowed to create at once.
 
int currentSourceIdx = 0
 The index of the next available audio source.
 
bool isInteractable = true
 A flag which controls whether the button is interactable.
 
bool allowHighlight = true
 A flag used to prevent butons from being re-highlighted after a button press when the mouse is still on the button.
 

Detailed Description

This is an implementation of a button component used by the dialogue display system.

Member Function Documentation

◆ Awake()

void EasyTalk.Display.DialogueButton.Awake ( )
private

Sets up various callbacks for mouse interactions.

◆ DisplayDisabled()

void EasyTalk.Display.DialogueButton.DisplayDisabled ( )

Sets the button to display itself in disabled mode.

◆ DisplayHighlighted()

void EasyTalk.Display.DialogueButton.DisplayHighlighted ( )

Sets the button to display itself in highlighted mode.

◆ DisplayNormal()

void EasyTalk.Display.DialogueButton.DisplayNormal ( )

Sets the button to display itself in normal mode.

◆ DisplayPressed()

void EasyTalk.Display.DialogueButton.DisplayPressed ( )

Sets the button to display itself in pressed mode.

◆ OnDisable()

void EasyTalk.Display.DialogueButton.OnDisable ( )
private

Removes all leftover on-demand audio sources from the button.

◆ OnPointerDown()

void EasyTalk.Display.DialogueButton.OnPointerDown ( PointerEventData eventData)

Called when the mouse is pressed over the button.

Parameters
eventData

◆ OnPointerEnter()

void EasyTalk.Display.DialogueButton.OnPointerEnter ( PointerEventData eventData)

Called when the mouse moves over the button.

Parameters
eventData

◆ OnPointerExit()

void EasyTalk.Display.DialogueButton.OnPointerExit ( PointerEventData eventData)

Called when the mouse leaves the button.

Parameters
eventData

◆ OnPointerUp()

void EasyTalk.Display.DialogueButton.OnPointerUp ( PointerEventData eventData)

Called when the mouse pointer is released over the button.

Parameters
eventData

◆ PlayHoverSound()

void EasyTalk.Display.DialogueButton.PlayHoverSound ( )

Plays the hover sound set on the button.

◆ PlaySoundAsync()

IEnumerator EasyTalk.Display.DialogueButton.PlaySoundAsync ( AudioSource source,
AudioClip clip )
private

Plays the provided sound asynchronously and removes the audio source from the on demand queue once the sound is finished playing.

Parameters
sourceThe audio source to use.
clipThe audio clip to play.
Returns

◆ SetText()

void EasyTalk.Display.DialogueButton.SetText ( string text)

Sets the text of the button.

Parameters
textThe text to use.

Member Data Documentation

◆ allowHighlight

bool EasyTalk.Display.DialogueButton.allowHighlight = true
private

A flag used to prevent butons from being re-highlighted after a button press when the mouse is still on the button.

◆ audioSource

AudioSource EasyTalk.Display.DialogueButton.audioSource
private

The audio source used by the button.

◆ backgroundImage

Image EasyTalk.Display.DialogueButton.backgroundImage

The image used for the button.

◆ currentSourceIdx

int EasyTalk.Display.DialogueButton.currentSourceIdx = 0
private

The index of the next available audio source.

◆ disabledButtonColor

Color EasyTalk.Display.DialogueButton.disabledButtonColor = new Color(0.15f, 0.15f, 0.15f)

The color of the image when the button is in 'disabled' mode.

◆ disabledTextColor

Color EasyTalk.Display.DialogueButton.disabledTextColor = new Color(0.4f, 0.4f, 0.4f)

The color of the text when the button is in 'disabled' mode.

◆ highlightedButtonColor

Color EasyTalk.Display.DialogueButton.highlightedButtonColor = new Color(0.5f, 0.5f, 0.5f)

The color of the image when the button is in 'highlighted' mode.

◆ highlightedTextColor

Color EasyTalk.Display.DialogueButton.highlightedTextColor = new Color(1.0f, 1.0f, 1.0f)

The color of the text when the button is in 'highlighted' mode.

◆ hoverSound

AudioClip EasyTalk.Display.DialogueButton.hoverSound

The sound to play when the player hovers over the button.

◆ isClickable

bool EasyTalk.Display.DialogueButton.isClickable = true
private

Whether the button is clickable.

◆ isClickReady

bool EasyTalk.Display.DialogueButton.isClickReady = false
private

A flag indicating whether the button is ready for a click to be completed (set to true when the button is pressed and the mouse is in the button's area).

◆ isInteractable

bool EasyTalk.Display.DialogueButton.isInteractable = true
private

A flag which controls whether the button is interactable.

◆ maxAudioSources

int EasyTalk.Display.DialogueButton.maxAudioSources = 4
private

The maximum number of audio sources the button is allowed to create at once.

◆ normalButtonColor

Color EasyTalk.Display.DialogueButton.normalButtonColor = new Color(0.3f, 0.3f, 0.3f)

The color of the image when the button is in 'normal' mode.

◆ normalTextColor

Color EasyTalk.Display.DialogueButton.normalTextColor = new Color(0.85f, 0.85f, 0.85f)

The color of the text when the button is in 'normal' mode.

◆ onClick

UnityEvent EasyTalk.Display.DialogueButton.onClick = new UnityEvent()

A Unity Event that gets triggered when the button is clicked.

◆ onDemandAudioSources

List<AudioSource> EasyTalk.Display.DialogueButton.onDemandAudioSources = new List<AudioSource>()
private

A collection of temporary audio sources used to queue up sounds to prevent hard cutoffs.

◆ onEnter

UnityEvent EasyTalk.Display.DialogueButton.onEnter = new UnityEvent()

A Unity Event that gets triggered when the button is entered by the mouse.

◆ onHighlighted

UnityEvent EasyTalk.Display.DialogueButton.onHighlighted = new UnityEvent()

A Unity Event that gets triggered when the button goes into 'highlighted' mode.

◆ onLeave

UnityEvent EasyTalk.Display.DialogueButton.onLeave = new UnityEvent()

A Unity Event that gets triggered when the button is left by the mouse.

◆ onNormal

UnityEvent EasyTalk.Display.DialogueButton.onNormal = new UnityEvent()

A Unity Event that gets triggered when the button goes into 'normal' mode.

◆ onPress

UnityEvent EasyTalk.Display.DialogueButton.onPress = new UnityEvent()

A Unity Event that gets triggered when the button is pressed down.

◆ pressedButtonColor

Color EasyTalk.Display.DialogueButton.pressedButtonColor = new Color(0.25f, 0.25f, 0.25f)

The color of the image when the button is in 'pressed' mode.

◆ pressedTextColor

Color EasyTalk.Display.DialogueButton.pressedTextColor = new Color(0.7f, 0.7f, 0.7f)

The color of the text when the button is in 'pressed' mode.

◆ text

Text EasyTalk.Display.DialogueButton.text
private

The text element of the button.

◆ value

object EasyTalk.Display.DialogueButton.value
private

A value attributed to the button.

Property Documentation

◆ Interactable

bool EasyTalk.Display.DialogueButton.Interactable
getset

A flag which controls whether the button is interactable.

◆ IsClickable

bool EasyTalk.Display.DialogueButton.IsClickable
getset

Whether the button is clickable. Returns false if the button is disabled. Setting this value to true will change the button to display in normal mode, and setting it to false will set it to display in disabled mode.

◆ StandardText

Text EasyTalk.Display.DialogueButton.StandardText
getset

Gets or sets the standard Unity Text component of the button.

◆ Value

object EasyTalk.Display.DialogueButton.Value
getset

Gets or sets the value attributed to the button.