Feel  5.1
The best way to improve your game's feel and make it extra juicy
Lofelt.NiceVibrations.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 Lofelt.NiceVibrations.MMTouchButton:
Lofelt.NiceVibrations.MMSwitch

Public Types

enum  ButtonStates {
  ButtonStates.Off, ButtonStates.ButtonDown, ButtonStates.ButtonPressed, ButtonStates.ButtonUp,
  ButtonStates.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

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
 
Sprite PressedSprite
 
Sprite HighlightedSprite
 
bool PressedChangeColor = false
 
Color PressedColor = Color.white
 
bool LerpColor = true
 
float LerpColorDuration = 0.2f
 
AnimationCurve LerpColorCurve
 
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 ()
 
virtual float Remap (float x, float A, float B, float C, float D)
 

Protected Attributes

bool _zonePressed = false
 
CanvasGroup _canvasGroup
 
float _initialOpacity
 
Animator _animator
 
Image _image
 
Sprite _initialSprite
 
Color _initialColor
 
float _lastClickTimestamp = 0f
 
Selectable _selectable
 
float _lastStateChangeAt = -50f
 
Color _imageColor
 
Color _fromColor
 
Color _toColor
 

Properties

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

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 Lofelt.NiceVibrations.MMTouchButton.Awake ( )
protectedvirtual

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

◆ DisableButton()

virtual void Lofelt.NiceVibrations.MMTouchButton.DisableButton ( )
virtual

◆ EnableButton()

virtual void Lofelt.NiceVibrations.MMTouchButton.EnableButton ( )
virtual

◆ Initialization()

virtual void Lofelt.NiceVibrations.MMTouchButton.Initialization ( )
protectedvirtual

Reimplemented in Lofelt.NiceVibrations.MMSwitch.

◆ InvokePressedFirstTime()

virtual void Lofelt.NiceVibrations.MMTouchButton.InvokePressedFirstTime ( )
protectedvirtual

◆ InvokeReleased()

virtual void Lofelt.NiceVibrations.MMTouchButton.InvokeReleased ( )
protectedvirtual

◆ LateUpdate()

virtual void Lofelt.NiceVibrations.MMTouchButton.LateUpdate ( )
protectedvirtual

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

◆ OnEnable()

virtual void Lofelt.NiceVibrations.MMTouchButton.OnEnable ( )
protectedvirtual

OnEnable, we reset our button state

◆ OnPointerDown()

virtual void Lofelt.NiceVibrations.MMTouchButton.OnPointerDown ( PointerEventData  data)
virtual

Triggers the bound pointer down action

◆ OnPointerEnter()

virtual void Lofelt.NiceVibrations.MMTouchButton.OnPointerEnter ( PointerEventData  data)
virtual

Triggers the bound pointer enter action when touch enters zone

◆ OnPointerExit()

virtual void Lofelt.NiceVibrations.MMTouchButton.OnPointerExit ( PointerEventData  data)
virtual

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

◆ OnPointerPressed()

virtual void Lofelt.NiceVibrations.MMTouchButton.OnPointerPressed ( )
virtual

Triggers the bound pointer pressed action

◆ OnPointerUp()

virtual void Lofelt.NiceVibrations.MMTouchButton.OnPointerUp ( PointerEventData  data)
virtual

Triggers the bound pointer up action

◆ OnSubmit()

virtual void Lofelt.NiceVibrations.MMTouchButton.OnSubmit ( BaseEventData  eventData)
virtual

◆ Remap()

virtual float Lofelt.NiceVibrations.MMTouchButton.Remap ( float  x,
float  A,
float  B,
float  C,
float  D 
)
protectedvirtual

◆ ResetButton()

virtual void Lofelt.NiceVibrations.MMTouchButton.ResetButton ( )
protectedvirtual

Resets the button's state and opacity

◆ SetOpacity()

virtual void Lofelt.NiceVibrations.MMTouchButton.SetOpacity ( float  newOpacity)
protectedvirtual

◆ Update()

virtual void Lofelt.NiceVibrations.MMTouchButton.Update ( )
protectedvirtual

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

Reimplemented in Lofelt.NiceVibrations.MMSwitch.

◆ UpdateAnimatorStates()

virtual void Lofelt.NiceVibrations.MMTouchButton.UpdateAnimatorStates ( )
protectedvirtual

Member Data Documentation

◆ _animator

Animator Lofelt.NiceVibrations.MMTouchButton._animator
protected

◆ _canvasGroup

CanvasGroup Lofelt.NiceVibrations.MMTouchButton._canvasGroup
protected

◆ _fromColor

Color Lofelt.NiceVibrations.MMTouchButton._fromColor
protected

◆ _image

Image Lofelt.NiceVibrations.MMTouchButton._image
protected

◆ _imageColor

Color Lofelt.NiceVibrations.MMTouchButton._imageColor
protected

◆ _initialColor

Color Lofelt.NiceVibrations.MMTouchButton._initialColor
protected

◆ _initialOpacity

float Lofelt.NiceVibrations.MMTouchButton._initialOpacity
protected

◆ _initialSprite

Sprite Lofelt.NiceVibrations.MMTouchButton._initialSprite
protected

◆ _lastClickTimestamp

float Lofelt.NiceVibrations.MMTouchButton._lastClickTimestamp = 0f
protected

◆ _lastStateChangeAt

float Lofelt.NiceVibrations.MMTouchButton._lastStateChangeAt = -50f
protected

◆ _selectable

Selectable Lofelt.NiceVibrations.MMTouchButton._selectable
protected

◆ _toColor

Color Lofelt.NiceVibrations.MMTouchButton._toColor
protected

◆ _zonePressed

bool Lofelt.NiceVibrations.MMTouchButton._zonePressed = false
protected

◆ Animator

Animator Lofelt.NiceVibrations.MMTouchButton.Animator

◆ BufferDuration

float Lofelt.NiceVibrations.MMTouchButton.BufferDuration = 0f

◆ ButtonPressed

UnityEvent Lofelt.NiceVibrations.MMTouchButton.ButtonPressed

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

◆ ButtonPressedFirstTime

UnityEvent Lofelt.NiceVibrations.MMTouchButton.ButtonPressedFirstTime

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

◆ ButtonReleased

UnityEvent Lofelt.NiceVibrations.MMTouchButton.ButtonReleased

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

◆ DisabledAnimationParameterName

string Lofelt.NiceVibrations.MMTouchButton.DisabledAnimationParameterName = "Disabled"

◆ DisabledOpacity

float Lofelt.NiceVibrations.MMTouchButton.DisabledOpacity = 1f

◆ DisabledSprite

Sprite Lofelt.NiceVibrations.MMTouchButton.DisabledSprite

◆ HighlightedSprite

Sprite Lofelt.NiceVibrations.MMTouchButton.HighlightedSprite

◆ IdleAnimationParameterName

string Lofelt.NiceVibrations.MMTouchButton.IdleAnimationParameterName = "Idle"

◆ IdleOpacity

float Lofelt.NiceVibrations.MMTouchButton.IdleOpacity = 1f

◆ LerpColor

bool Lofelt.NiceVibrations.MMTouchButton.LerpColor = true

◆ LerpColorCurve

AnimationCurve Lofelt.NiceVibrations.MMTouchButton.LerpColorCurve

◆ LerpColorDuration

float Lofelt.NiceVibrations.MMTouchButton.LerpColorDuration = 0.2f

◆ MouseMode

bool Lofelt.NiceVibrations.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 Lofelt.NiceVibrations.MMTouchButton.PressedAnimationParameterName = "Pressed"

◆ PressedChangeColor

bool Lofelt.NiceVibrations.MMTouchButton.PressedChangeColor = false

◆ PressedColor

Color Lofelt.NiceVibrations.MMTouchButton.PressedColor = Color.white

◆ PressedFirstTimeDelay

float Lofelt.NiceVibrations.MMTouchButton.PressedFirstTimeDelay = 0f

◆ PressedOpacity

float Lofelt.NiceVibrations.MMTouchButton.PressedOpacity = 1f

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

◆ PressedSprite

Sprite Lofelt.NiceVibrations.MMTouchButton.PressedSprite

◆ ReleasedDelay

float Lofelt.NiceVibrations.MMTouchButton.ReleasedDelay = 0f

Property Documentation

◆ CurrentState

ButtonStates Lofelt.NiceVibrations.MMTouchButton.CurrentState
getprotected set

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

◆ ReturnToInitialSpriteAutomatically

bool Lofelt.NiceVibrations.MMTouchButton.ReturnToInitialSpriteAutomatically
getset

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