Feel 5.9.1
The best way to improve your game's feel and make it extra juicy
Loading...
Searching...
No Matches
Lofelt.NiceVibrations.MMSwitch Class Reference

A component to handle switches. More...

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

Public Types

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

Public Member Functions

virtual void InitializeState ()
virtual void SwitchState ()
 Use this method to go from one state to the other.
Public Member Functions inherited from Lofelt.NiceVibrations.MMTouchButton
virtual void OnPointerDown (PointerEventData data)
 Triggers the bound pointer down action.
virtual void OnPointerUp (PointerEventData data)
 Triggers the bound pointer up action.
virtual void OnPointerPressed ()
 Triggers the bound pointer pressed action.
virtual void OnPointerEnter (PointerEventData data)
 Triggers the bound pointer enter action when touch enters zone.
virtual void OnPointerExit (PointerEventData data)
 Triggers the bound pointer exit action when touch is out of zone.
virtual void DisableButton ()
virtual void EnableButton ()
virtual void OnSubmit (BaseEventData eventData)

Public Attributes

Image SwitchKnob
 a SpriteReplace to represent the switch knob
SwitchStates InitialState = SwitchStates.Off
 the state the switch should start in
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
UnityEvent SwitchOff
 the methods to call when the switch is turned off
Public Attributes inherited from Lofelt.NiceVibrations.MMTouchButton
UnityEvent ButtonPressedFirstTime
 The method(s) to call when the button gets pressed down.
UnityEvent ButtonReleased
 The method(s) to call when the button gets released.
UnityEvent ButtonPressed
 The method(s) to call while the button is being pressed.
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
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).

Protected Member Functions

override void Initialization ()
 On init, we set our current switch state.
override void Update ()
 Every frame, if the touch zone is pressed, we trigger the OnPointerPressed method, to detect continuous press.
Protected Member Functions inherited from Lofelt.NiceVibrations.MMTouchButton
virtual void Awake ()
 On Start, we get our canvasgroup and set our initial alpha.
virtual void LateUpdate ()
 At the end of every frame, we change our button's state if needed.
virtual void InvokePressedFirstTime ()
virtual void InvokeReleased ()
virtual void ResetButton ()
 Resets the button's state and opacity.
virtual void OnEnable ()
 OnEnable, we reset our button state.
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
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)

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:
  • H:/Code/MoreMountains/feel/Assets/Feel/NiceVibrations/Demo/Common/Scripts/UI/MMSwitch.cs