TopDown Engine  v3.6
MoreMountains.MMInterface.MMSwitch Class Reference

A component to handle switches More...

Inheritance diagram for MoreMountains.MMInterface.MMSwitch:
MoreMountains.Tools.MMTouchButton

Public Types

enum  SwitchStates { SwitchStates.Left, SwitchStates.Right }
 the possible states of the switch More...
 
- Public Types inherited from MoreMountains.Tools.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 MoreMountains.Tools.MMTouchButton
virtual void InvokeButtonStateChange (PointerEventData.FramePressState newState, PointerEventData data)
 Triggers the ButtonStateChange event for the specified state More...
 
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 ()
 Prevents the button from receiving touches More...
 
virtual void EnableButton ()
 Allows the button to receive touches More...
 
virtual void OnSubmit (BaseEventData eventData)
 On submit, raises the appropriate events More...
 

Public Attributes

MMSpriteReplace SwitchKnob
 a SpriteReplace to represent the switch knob More...
 
SwitchStates InitialState = SwitchStates.Left
 the state the switch should start in More...
 
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 MoreMountains.Tools.MMTouchButton
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
 the sprite to use on the button when it's in the disabled state More...
 
bool DisabledChangeColor = false
 whether or not to change color when the button is disabled More...
 
Color DisabledColor = Color.white
 the color to use when the button is disabled More...
 
Sprite PressedSprite
 the sprite to use on the button when it's in the pressed state More...
 
bool PressedChangeColor = false
 whether or not to change the button color on press More...
 
Color PressedColor = Color.white
 the color to use when the button is pressed More...
 
Sprite HighlightedSprite
 the sprite to use on the button when it's in the highlighted state More...
 
bool HighlightedChangeColor = false
 whether or not to change color when highlighting the button More...
 
Color HighlightedColor = Color.white
 the color to use when the button is highlighted More...
 
float PressedOpacity = 1f
 the new opacity to apply to the canvas group when the button is pressed More...
 
float IdleOpacity = 1f
 the new opacity to apply to the canvas group when the button is idle More...
 
float DisabledOpacity = 1f
 the new opacity to apply to the canvas group when the button is disabled More...
 
float PressedFirstTimeDelay = 0f
 the delay to apply to events when the button gets pressed for the first time More...
 
float ReleasedDelay = 0f
 the delay to apply to events when the button gets released More...
 
float BufferDuration = 0f
 the duration (in seconds) after a press during which the button can't be pressed again More...
 
Animator Animator
 an animator you can bind to this button to have its states updated to reflect the button's states More...
 
string IdleAnimationParameterName = "Idle"
 the name of the animation parameter to turn true when the button is idle More...
 
string DisabledAnimationParameterName = "Disabled"
 the name of the animation parameter to turn true when the button is disabled More...
 
string PressedAnimationParameterName = "Pressed"
 the name of the animation parameter to turn true when the button is pressed More...
 
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...
 
- Protected Member Functions inherited from MoreMountains.Tools.MMTouchButton
virtual void Awake ()
 On Start, we get our canvasgroup and set our initial alpha More...
 
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 ()
 Raises the ButtonPressedFirstTime event More...
 
virtual void InvokeReleased ()
 Invokes the ButtonReleased event More...
 
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)
 Sets the canvas group's opacity to the requested value More...
 
virtual void UpdateAnimatorStates ()
 Updates animator states based on the current state of the button More...
 

Properties

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

Additional Inherited Members

- Protected Attributes inherited from MoreMountains.Tools.MMTouchButton
bool _zonePressed = false
 
CanvasGroup _canvasGroup
 
float _initialOpacity
 
Animator _animator
 
Image _image
 
Sprite _initialSprite
 
Color _initialColor
 
float _lastClickTimestamp = 0f
 
Selectable _selectable
 
- Events inherited from MoreMountains.Tools.MMTouchButton
System.Action< PointerEventData.FramePressState, PointerEventData > ButtonStateChange
 

Detailed Description

A component to handle switches

Member Enumeration Documentation

◆ SwitchStates

the possible states of the switch

Enumerator
Left 
Right 

Member Function Documentation

◆ Initialization()

override void MoreMountains.MMInterface.MMSwitch.Initialization ( )
protectedvirtual

On init, we set our current switch state

Reimplemented from MoreMountains.Tools.MMTouchButton.

◆ InitializeState()

virtual void MoreMountains.MMInterface.MMSwitch.InitializeState ( )
virtual

◆ SwitchState()

virtual void MoreMountains.MMInterface.MMSwitch.SwitchState ( )
virtual

Use this method to go from one state to the other

Member Data Documentation

◆ InitialState

SwitchStates MoreMountains.MMInterface.MMSwitch.InitialState = SwitchStates.Left

the state the switch should start in

◆ SwitchKnob

MMSpriteReplace MoreMountains.MMInterface.MMSwitch.SwitchKnob

a SpriteReplace to represent the switch knob

◆ SwitchOff

UnityEvent MoreMountains.MMInterface.MMSwitch.SwitchOff

the methods to call when the switch is turned off

◆ SwitchOn

UnityEvent MoreMountains.MMInterface.MMSwitch.SwitchOn

the methods to call when the switch is turned on

Property Documentation

◆ CurrentSwitchState

SwitchStates MoreMountains.MMInterface.MMSwitch.CurrentSwitchState
getset

the current state of the switch


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