Highroad Engine v1.3
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Properties | Events | List of all members
MoreMountains.Tools.MMTouchButton Class Reference

Add this component to a GUI Image to have it act as a button. Bind pressed down, pressed continually and released actions to it from the inspector Handles mouse and multi touch More...

Inheritance diagram for MoreMountains.Tools.MMTouchButton:
MoreMountains.Tools.MMDebugMenuSwitch

Public Types

enum  ButtonStates {
  Off , ButtonDown , ButtonPressed , ButtonUp ,
  Disabled
}
 

Public Member Functions

virtual void OnPointerDown (PointerEventData data)
 Triggers the bound pointer down action More...
 
virtual void OnPointerUp (PointerEventData data)
 Triggers the bound pointer up action More...
 
virtual void OnPointerPressed ()
 Triggers the bound pointer pressed action More...
 
virtual void OnPointerEnter (PointerEventData data)
 Triggers the bound pointer enter action when touch enters zone More...
 
virtual void OnPointerExit (PointerEventData data)
 Triggers the bound pointer exit action when touch is out of zone More...
 
virtual void DisableButton ()
 
virtual void EnableButton ()
 
virtual void OnSubmit (BaseEventData eventData)
 

Public Attributes

bool Interactable = true
 whether or not this button can be interacted with More...
 
UnityEvent ButtonPressedFirstTime
 The method(s) to call when the button gets pressed down. More...
 
UnityEvent ButtonReleased
 The method(s) to call when the button gets released. More...
 
UnityEvent ButtonPressed
 The method(s) to call while the button is being pressed. More...
 
Sprite DisabledSprite
 
bool DisabledChangeColor = false
 
Color DisabledColor = Color.white
 
Sprite PressedSprite
 
bool PressedChangeColor = false
 
Color PressedColor = Color.white
 
Sprite HighlightedSprite
 
bool HighlightedChangeColor = false
 
Color HighlightedColor = Color.white
 
float PressedOpacity = 1f
 the new opacity to apply to the canvas group when the button is pressed More...
 
float IdleOpacity = 1f
 
float DisabledOpacity = 1f
 
float PressedFirstTimeDelay = 0f
 
float ReleasedDelay = 0f
 
float BufferDuration = 0f
 
Animator Animator
 
string IdleAnimationParameterName = "Idle"
 
string DisabledAnimationParameterName = "Disabled"
 
string PressedAnimationParameterName = "Pressed"
 
bool MouseMode = false
 If you set this to true, you'll need to actually press the button for it to be triggered, otherwise a simple hover will trigger it (better for touch input). More...
 

Protected Member Functions

virtual void Awake ()
 On Start, we get our canvasgroup and set our initial alpha More...
 
virtual void Initialization ()
 
virtual void Update ()
 Every frame, if the touch zone is pressed, we trigger the OnPointerPressed method, to detect continuous press More...
 
virtual void LateUpdate ()
 At the end of every frame, we change our button's state if needed More...
 
virtual void InvokePressedFirstTime ()
 
virtual void InvokeReleased ()
 
virtual void ResetButton ()
 Resets the button's state and opacity More...
 
virtual void OnEnable ()
 OnEnable, we reset our button state More...
 
virtual void SetOpacity (float newOpacity)
 
virtual void UpdateAnimatorStates ()
 

Protected Attributes

bool _zonePressed = false
 
CanvasGroup _canvasGroup
 
float _initialOpacity
 
Animator _animator
 
Image _image
 
Sprite _initialSprite
 
Color _initialColor
 
float _lastClickTimestamp = 0f
 
Selectable _selectable
 

Properties

bool ReturnToInitialSpriteAutomatically [getset]
 
ButtonStates CurrentState [getprotected set]
 the current state of the button (off, down, pressed or up) More...
 

Events

System.Action< PointerEventData.FramePressState, PointerEventData > ButtonStateChange
 

Detailed Description

Add this component to a GUI Image to have it act as a button. Bind pressed down, pressed continually and released actions to it from the inspector Handles mouse and multi touch

Member Enumeration Documentation

◆ ButtonStates

The different possible states for the button : Off (default idle state), ButtonDown (button pressed for the first time), ButtonPressed (button being pressed), ButtonUp (button being released), Disabled (unclickable but still present on screen) ButtonDown and ButtonUp will only last one frame, the others will last however long you press them / disable them / do nothing

Enumerator
Off 
ButtonDown 
ButtonPressed 
ButtonUp 
Disabled 

Member Function Documentation

◆ Awake()

virtual void MoreMountains.Tools.MMTouchButton.Awake ( )
protectedvirtual

On Start, we get our canvasgroup and set our initial alpha

◆ DisableButton()

virtual void MoreMountains.Tools.MMTouchButton.DisableButton ( )
virtual

◆ EnableButton()

virtual void MoreMountains.Tools.MMTouchButton.EnableButton ( )
virtual

◆ Initialization()

virtual void MoreMountains.Tools.MMTouchButton.Initialization ( )
protectedvirtual

◆ InvokePressedFirstTime()

virtual void MoreMountains.Tools.MMTouchButton.InvokePressedFirstTime ( )
protectedvirtual

◆ InvokeReleased()

virtual void MoreMountains.Tools.MMTouchButton.InvokeReleased ( )
protectedvirtual

◆ LateUpdate()

virtual void MoreMountains.Tools.MMTouchButton.LateUpdate ( )
protectedvirtual

At the end of every frame, we change our button's state if needed

◆ OnEnable()

virtual void MoreMountains.Tools.MMTouchButton.OnEnable ( )
protectedvirtual

OnEnable, we reset our button state

◆ OnPointerDown()

virtual void MoreMountains.Tools.MMTouchButton.OnPointerDown ( PointerEventData  data)
virtual

Triggers the bound pointer down action

◆ OnPointerEnter()

virtual void MoreMountains.Tools.MMTouchButton.OnPointerEnter ( PointerEventData  data)
virtual

Triggers the bound pointer enter action when touch enters zone

◆ OnPointerExit()

virtual void MoreMountains.Tools.MMTouchButton.OnPointerExit ( PointerEventData  data)
virtual

Triggers the bound pointer exit action when touch is out of zone

◆ OnPointerPressed()

virtual void MoreMountains.Tools.MMTouchButton.OnPointerPressed ( )
virtual

Triggers the bound pointer pressed action

◆ OnPointerUp()

virtual void MoreMountains.Tools.MMTouchButton.OnPointerUp ( PointerEventData  data)
virtual

Triggers the bound pointer up action

◆ OnSubmit()

virtual void MoreMountains.Tools.MMTouchButton.OnSubmit ( BaseEventData  eventData)
virtual

◆ ResetButton()

virtual void MoreMountains.Tools.MMTouchButton.ResetButton ( )
protectedvirtual

Resets the button's state and opacity

◆ SetOpacity()

virtual void MoreMountains.Tools.MMTouchButton.SetOpacity ( float  newOpacity)
protectedvirtual

◆ Update()

virtual void MoreMountains.Tools.MMTouchButton.Update ( )
protectedvirtual

Every frame, if the touch zone is pressed, we trigger the OnPointerPressed method, to detect continuous press

◆ UpdateAnimatorStates()

virtual void MoreMountains.Tools.MMTouchButton.UpdateAnimatorStates ( )
protectedvirtual

Member Data Documentation

◆ _animator

Animator MoreMountains.Tools.MMTouchButton._animator
protected

◆ _canvasGroup

CanvasGroup MoreMountains.Tools.MMTouchButton._canvasGroup
protected

◆ _image

Image MoreMountains.Tools.MMTouchButton._image
protected

◆ _initialColor

Color MoreMountains.Tools.MMTouchButton._initialColor
protected

◆ _initialOpacity

float MoreMountains.Tools.MMTouchButton._initialOpacity
protected

◆ _initialSprite

Sprite MoreMountains.Tools.MMTouchButton._initialSprite
protected

◆ _lastClickTimestamp

float MoreMountains.Tools.MMTouchButton._lastClickTimestamp = 0f
protected

◆ _selectable

Selectable MoreMountains.Tools.MMTouchButton._selectable
protected

◆ _zonePressed

bool MoreMountains.Tools.MMTouchButton._zonePressed = false
protected

◆ Animator

Animator MoreMountains.Tools.MMTouchButton.Animator

◆ BufferDuration

float MoreMountains.Tools.MMTouchButton.BufferDuration = 0f

◆ ButtonPressed

UnityEvent MoreMountains.Tools.MMTouchButton.ButtonPressed

The method(s) to call while the button is being pressed.

◆ ButtonPressedFirstTime

UnityEvent MoreMountains.Tools.MMTouchButton.ButtonPressedFirstTime

The method(s) to call when the button gets pressed down.

◆ ButtonReleased

UnityEvent MoreMountains.Tools.MMTouchButton.ButtonReleased

The method(s) to call when the button gets released.

◆ DisabledAnimationParameterName

string MoreMountains.Tools.MMTouchButton.DisabledAnimationParameterName = "Disabled"

◆ DisabledChangeColor

bool MoreMountains.Tools.MMTouchButton.DisabledChangeColor = false

◆ DisabledColor

Color MoreMountains.Tools.MMTouchButton.DisabledColor = Color.white

◆ DisabledOpacity

float MoreMountains.Tools.MMTouchButton.DisabledOpacity = 1f

◆ DisabledSprite

Sprite MoreMountains.Tools.MMTouchButton.DisabledSprite

◆ HighlightedChangeColor

bool MoreMountains.Tools.MMTouchButton.HighlightedChangeColor = false

◆ HighlightedColor

Color MoreMountains.Tools.MMTouchButton.HighlightedColor = Color.white

◆ HighlightedSprite

Sprite MoreMountains.Tools.MMTouchButton.HighlightedSprite

◆ IdleAnimationParameterName

string MoreMountains.Tools.MMTouchButton.IdleAnimationParameterName = "Idle"

◆ IdleOpacity

float MoreMountains.Tools.MMTouchButton.IdleOpacity = 1f

◆ Interactable

bool MoreMountains.Tools.MMTouchButton.Interactable = true

whether or not this button can be interacted with

◆ MouseMode

bool MoreMountains.Tools.MMTouchButton.MouseMode = false

If you set this to true, you'll need to actually press the button for it to be triggered, otherwise a simple hover will trigger it (better for touch input).

◆ PressedAnimationParameterName

string MoreMountains.Tools.MMTouchButton.PressedAnimationParameterName = "Pressed"

◆ PressedChangeColor

bool MoreMountains.Tools.MMTouchButton.PressedChangeColor = false

◆ PressedColor

Color MoreMountains.Tools.MMTouchButton.PressedColor = Color.white

◆ PressedFirstTimeDelay

float MoreMountains.Tools.MMTouchButton.PressedFirstTimeDelay = 0f

◆ PressedOpacity

float MoreMountains.Tools.MMTouchButton.PressedOpacity = 1f

the new opacity to apply to the canvas group when the button is pressed

◆ PressedSprite

Sprite MoreMountains.Tools.MMTouchButton.PressedSprite

◆ ReleasedDelay

float MoreMountains.Tools.MMTouchButton.ReleasedDelay = 0f

Property Documentation

◆ CurrentState

ButtonStates MoreMountains.Tools.MMTouchButton.CurrentState
getprotected set

the current state of the button (off, down, pressed or up)

◆ ReturnToInitialSpriteAutomatically

bool MoreMountains.Tools.MMTouchButton.ReturnToInitialSpriteAutomatically
getset

Event Documentation

◆ ButtonStateChange

System.Action<PointerEventData.FramePressState, PointerEventData> MoreMountains.Tools.MMTouchButton.ButtonStateChange

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