EasyTalk API
|
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. | |
This is an implementation of a button component used by the dialogue display system.
|
private |
Sets up various callbacks for mouse interactions.
void EasyTalk.Display.DialogueButton.DisplayDisabled | ( | ) |
Sets the button to display itself in disabled mode.
void EasyTalk.Display.DialogueButton.DisplayHighlighted | ( | ) |
Sets the button to display itself in highlighted mode.
void EasyTalk.Display.DialogueButton.DisplayNormal | ( | ) |
Sets the button to display itself in normal mode.
void EasyTalk.Display.DialogueButton.DisplayPressed | ( | ) |
Sets the button to display itself in pressed mode.
|
private |
Removes all leftover on-demand audio sources from the button.
void EasyTalk.Display.DialogueButton.OnPointerDown | ( | PointerEventData | eventData | ) |
Called when the mouse is pressed over the button.
eventData |
void EasyTalk.Display.DialogueButton.OnPointerEnter | ( | PointerEventData | eventData | ) |
Called when the mouse moves over the button.
eventData |
void EasyTalk.Display.DialogueButton.OnPointerExit | ( | PointerEventData | eventData | ) |
Called when the mouse leaves the button.
eventData |
void EasyTalk.Display.DialogueButton.OnPointerUp | ( | PointerEventData | eventData | ) |
Called when the mouse pointer is released over the button.
eventData |
void EasyTalk.Display.DialogueButton.PlayHoverSound | ( | ) |
Plays the hover sound set on the button.
|
private |
Plays the provided sound asynchronously and removes the audio source from the on demand queue once the sound is finished playing.
source | The audio source to use. |
clip | The audio clip to play. |
void EasyTalk.Display.DialogueButton.SetText | ( | string | text | ) |
Sets the text of the button.
text | The text to use. |
|
private |
A flag used to prevent butons from being re-highlighted after a button press when the mouse is still on the button.
|
private |
The audio source used by the button.
Image EasyTalk.Display.DialogueButton.backgroundImage |
The image used for the button.
|
private |
The index of the next available audio source.
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.
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.
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.
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.
AudioClip EasyTalk.Display.DialogueButton.hoverSound |
The sound to play when the player hovers over the button.
|
private |
Whether the button is clickable.
|
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).
|
private |
A flag which controls whether the button is interactable.
|
private |
The maximum number of audio sources the button is allowed to create at once.
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.
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.
UnityEvent EasyTalk.Display.DialogueButton.onClick = new UnityEvent() |
A Unity Event that gets triggered when the button is clicked.
|
private |
A collection of temporary audio sources used to queue up sounds to prevent hard cutoffs.
UnityEvent EasyTalk.Display.DialogueButton.onEnter = new UnityEvent() |
A Unity Event that gets triggered when the button is entered by the mouse.
UnityEvent EasyTalk.Display.DialogueButton.onHighlighted = new UnityEvent() |
A Unity Event that gets triggered when the button goes into 'highlighted' mode.
UnityEvent EasyTalk.Display.DialogueButton.onLeave = new UnityEvent() |
A Unity Event that gets triggered when the button is left by the mouse.
UnityEvent EasyTalk.Display.DialogueButton.onNormal = new UnityEvent() |
A Unity Event that gets triggered when the button goes into 'normal' mode.
UnityEvent EasyTalk.Display.DialogueButton.onPress = new UnityEvent() |
A Unity Event that gets triggered when the button is pressed down.
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.
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.
|
private |
The text element of the button.
|
private |
A value attributed to the button.
|
getset |
A flag which controls whether the button is interactable.
|
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.
|
getset |
Gets or sets the standard Unity Text component of the button.
|
getset |
Gets or sets the value attributed to the button.