Feel  5.1
The best way to improve your game's feel and make it extra juicy
Lofelt.NiceVibrations.MMSwitch Class Reference

A component to handle switches More...

Inheritance diagram for Lofelt.NiceVibrations.MMSwitch:
Lofelt.NiceVibrations.MMTouchButton

Public Types

enum  SwitchStates { SwitchStates.Off, SwitchStates.On }
 the possible states of the switch More...
 
- Public Types inherited from Lofelt.NiceVibrations.MMTouchButton
enum  ButtonStates {
  ButtonStates.Off, ButtonStates.ButtonDown, ButtonStates.ButtonPressed, ButtonStates.ButtonUp,
  ButtonStates.Disabled
}
 

Public Member Functions

virtual void InitializeState ()
 
virtual void SwitchState ()
 Use this method to go from one state to the other More...
 
- Public Member Functions inherited from Lofelt.NiceVibrations.MMTouchButton
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

Image SwitchKnob
 a SpriteReplace to represent the switch knob More...
 
SwitchStates InitialState = SwitchStates.Off
 the state the switch should start in More...
 
Transform OffPosition
 
Transform OnPosition
 
AnimationCurve KnobMovementCurve = AnimationCurve.Linear(0f, 0f, 1f, 1f)
 
float KnobMovementDuration = 0.2f
 
UnityEvent SwitchOn
 the methods to call when the switch is turned on More...
 
UnityEvent SwitchOff
 the methods to call when the switch is turned off More...
 
- Public Attributes inherited from Lofelt.NiceVibrations.MMTouchButton
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

override void Initialization ()
 On init, we set our current switch state More...
 
override void Update ()
 Every frame, if the touch zone is pressed, we trigger the OnPointerPressed method, to detect continuous press More...
 
- Protected Member Functions inherited from Lofelt.NiceVibrations.MMTouchButton
virtual void Awake ()
 On Start, we get our canvasgroup and set our initial alpha 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

float _knobMovementStartedAt = -50f
 
- Protected Attributes inherited from Lofelt.NiceVibrations.MMTouchButton
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

SwitchStates CurrentSwitchState [get, set]
 the current state of the switch More...
 
- Properties inherited from Lofelt.NiceVibrations.MMTouchButton
bool ReturnToInitialSpriteAutomatically [get, set]
 
ButtonStates CurrentState [get, protected set]
 the current state of the button (off, down, pressed or up) More...
 

Detailed Description

A component to handle switches

Member Enumeration Documentation

◆ SwitchStates

the possible states of the switch

Enumerator
Off 
On 

Member Function Documentation

◆ Initialization()

override void Lofelt.NiceVibrations.MMSwitch.Initialization ( )
protectedvirtual

On init, we set our current switch state

Reimplemented from Lofelt.NiceVibrations.MMTouchButton.

◆ InitializeState()

virtual void Lofelt.NiceVibrations.MMSwitch.InitializeState ( )
virtual

◆ SwitchState()

virtual void Lofelt.NiceVibrations.MMSwitch.SwitchState ( )
virtual

Use this method to go from one state to the other

◆ Update()

override void Lofelt.NiceVibrations.MMSwitch.Update ( )
protectedvirtual

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

Reimplemented from Lofelt.NiceVibrations.MMTouchButton.

Member Data Documentation

◆ _knobMovementStartedAt

float Lofelt.NiceVibrations.MMSwitch._knobMovementStartedAt = -50f
protected

◆ InitialState

SwitchStates Lofelt.NiceVibrations.MMSwitch.InitialState = SwitchStates.Off

the state the switch should start in

◆ KnobMovementCurve

AnimationCurve Lofelt.NiceVibrations.MMSwitch.KnobMovementCurve = AnimationCurve.Linear(0f, 0f, 1f, 1f)

◆ KnobMovementDuration

float Lofelt.NiceVibrations.MMSwitch.KnobMovementDuration = 0.2f

◆ OffPosition

Transform Lofelt.NiceVibrations.MMSwitch.OffPosition

◆ OnPosition

Transform Lofelt.NiceVibrations.MMSwitch.OnPosition

◆ SwitchKnob

Image Lofelt.NiceVibrations.MMSwitch.SwitchKnob

a SpriteReplace to represent the switch knob

◆ SwitchOff

UnityEvent Lofelt.NiceVibrations.MMSwitch.SwitchOff

the methods to call when the switch is turned off

◆ SwitchOn

UnityEvent Lofelt.NiceVibrations.MMSwitch.SwitchOn

the methods to call when the switch is turned on

Property Documentation

◆ CurrentSwitchState

SwitchStates Lofelt.NiceVibrations.MMSwitch.CurrentSwitchState
getset

the current state of the switch


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