Feel  3.16
The best way to improve your game's feel and make it extra juicy
MoreMountains.Tools.MMTouchFollowerJoystick Class Reference

Add this component to a UI rectangle and it'll act as a detection zone for a follower joystick. Note that this component extends the MMTouchJoystick class so you don't need to add another joystick to it. It's both the detection zone and the stick itself. More...

Inheritance diagram for MoreMountains.Tools.MMTouchFollowerJoystick:
MoreMountains.Tools.MMTouchJoystick MoreMountains.Tools.MMMonoBehaviour

Public Member Functions

override void Initialize ()
 On initialize, we set our knob transform More...
 
override void OnPointerDown (PointerEventData data)
 When the zone is pressed, we move our joystick accordingly More...
 
override void OnDrag (PointerEventData eventData)
 On drag, we adjust our target and constrain our background More...
 
override void OnPointerUp (PointerEventData data)
 On pointer up we reset our joystick More...
 
- Public Member Functions inherited from MoreMountains.Tools.MMTouchJoystick
virtual void RefreshMaxRangeDistance ()
 This method is used to compute the max range distance when in DistanceToTransform mode More...
 
virtual void SetKnobTransform (Transform newTransform)
 Assigns a new transform as the joystick knob More...
 
virtual void SetNeutralPosition ()
 Sets the neutral position of the joystick More...
 
virtual void SetNeutralPosition (Vector3 newPosition)
 
virtual void ResetJoystick ()
 Resets the stick's position and values More...
 
virtual void OnEndDrag (PointerEventData eventData)
 What happens when the stick stops being dragged More...
 

Public Attributes

CanvasGroup KnobCanvasGroup
 the canvas group to use as the joystick's knob - the part that moves under your thumb More...
 
CanvasGroup BackgroundCanvasGroup
 the canvas group to use as the joystick's background More...
 
bool ResetPositionToInitialOnRelease = false
 if this is true, the joystick will return back to its initial position when released More...
 
bool InterpolateFollowMovement = false
 if this is true, the background will follow its target with interpolation, otherwise it'll be instant movement More...
 
float InterpolateFollowMovementSpeed = 0.3f
 if in interpolate mode, this defines the speed at which the backgrounds follows the knob More...
 
bool SpringFollowInterpolation = false
 whether or not to add a spring to the interpolation of the background movement More...
 
float SpringDamping = 0.6f
 when in SpringFollowInterpolation mode, the amount of damping to apply to the spring More...
 
float SpringFrequency = 4f
 when in SpringFollowInterpolation mode, the frequency to apply to the spring More...
 
bool ShouldConstrainBackground = true
 if this is true, the joystick won't be able to travel beyond the bounds of the top level canvas More...
 
RectTransform BackgroundConstraintRectTransform
 the rect to consider as a background constraint zone, if left empty, will be auto created More...
 
float BackgroundConstraintPaddingLeft
 the left padding to apply to the background constraint More...
 
float BackgroundConstraintPaddingRight
 the right padding to apply to the background constraint More...
 
float BackgroundConstraintPaddingTop
 the top padding to apply to the background constraint More...
 
float BackgroundConstraintPaddingBottom
 the bottom padding to apply to the background constraint More...
 
- Public Attributes inherited from MoreMountains.Tools.MMTouchJoystick
Camera TargetCamera
 The camera to use as the reference for any ScreenToWorldPoint computations. More...
 
bool HorizontalAxisEnabled = true
 Is horizontal axis allowed. More...
 
bool VerticalAxisEnabled = true
 Is vertical axis allowed. More...
 
MaxRangeModes MaxRangeMode = MaxRangeModes.Distance
 the mode in which to compute the range. Distance will be a flat value, DistanceToTransform will be a distance to a transform you can move around and potentially resize as you wish for various resolutions More...
 
float MaxRange = 1.5f
 The MaxRange is the maximum distance from its initial center position you can drag the joystick to. More...
 
Transform MaxRangeTransform
 in DistanceToTransform mode, the object whose distance to the center will be used to compute the max range. Note that this is computed once, at init. Call RefreshMaxRangeDistance() to recompute it. More...
 
JoystickEvent JoystickValue
 An event to use the raw value of the joystick. More...
 
JoystickEvent JoystickNormalizedValue
 An event to use the normalized value of the joystick. More...
 
JoystickFloatEvent JoystickMagnitudeValue
 
UnityEvent OnPointerDownEvent
 An event triggered when tapping the joystick for the first time. More...
 
UnityEvent OnDragEvent
 An event triggered when dragging the stick. More...
 
UnityEvent OnPointerUpEvent
 An event triggered when releasing the stick. More...
 
Transform RotatingIndicator
 an object you can rotate to show the direction of the joystick. Will only be visible if the movement is above a threshold More...
 
float RotatingIndicatorThreshold = 0.1f
 the threshold above which the rotating indicator will appear More...
 
float PressedOpacity = 0.5f
 the new opacity to apply to the canvas group when the button is pressed More...
 
bool InterpolateOpacity = true
 whether or not to interpolate opacity changes on the knob's canvas group More...
 
float InterpolateOpacitySpeed = 1f
 the speed at which to interpolate opacity More...
 
Vector2 RawValue
 the raw value of the joystick, from 0 to 1 on each axis More...
 
Vector2 NormalizedValue
 the normalized value of the joystick More...
 
float Magnitude
 the magnitude of the stick's vector More...
 
bool DrawGizmos = true
 whether or not to draw gizmos associated to this stick More...
 

Protected Member Functions

override void Start ()
 On Start, we instantiate our joystick's image if there's one More...
 
override void Update ()
 On update, we handle movement interpolation More...
 
virtual void HandleMovementInterpolation ()
 Handles the movement of the background relative to the knob More...
 
virtual void CreateInnerRect ()
 Creates a constraining inner rect More...
 
virtual void ComputeJoystickValue ()
 Determines the value of the joystick by computing the More...
 
virtual void ConstrainBackground ()
 Clamps the background inside the inner rect More...
 
override void ClampToBounds ()
 We don't clamp the stick anymore More...
 
- Protected Member Functions inherited from MoreMountains.Tools.MMTouchJoystick
virtual void HandleOpacity ()
 Changes or interpolates the opacity of the knob More...
 
virtual void RotateIndicator ()
 Rotates an indicator to match the rotation of the stick More...
 
virtual Vector3 ConvertToWorld (Vector3 position)
 Converts a position to world position More...
 
virtual float EvaluateInputValue (float vectorPosition)
 We compute the axis value from the interval between neutral position, current stick position (vectorPosition) and max range More...
 
virtual void OnEnable ()
 On enable, we initialize our stick More...
 

Protected Attributes

Vector3 _initialPosition
 
Vector3 _newPosition
 
RectTransform _rectTransform
 
RectTransform _backgroundRectTransform
 
Vector3[] _innerRectCorners = new Vector3[4]
 
Vector3 _newBackgroundPosition
 
Vector3 _backgroundPositionTarget
 
Vector3 _innerRectTransformBottomLeft
 
Vector3 _innerRectTransformTopLeft
 
Vector3 _innerRectTransformTopRight
 
Vector3 _innerRectTransformBottomRight
 
Vector3 _springVelocity
 
- Protected Attributes inherited from MoreMountains.Tools.MMTouchJoystick
Vector2 _neutralPosition
 
Vector2 _newTargetPosition
 
Vector3 _newJoystickPosition
 
float _initialZPosition
 
float _targetOpacity
 
CanvasGroup _canvasGroup
 
float _initialOpacity
 
Transform _knobTransform
 
bool _rotatingIndicatorIsNotNull = false
 
float _maxRangeTransformDistance
 

Additional Inherited Members

- Public Types inherited from MoreMountains.Tools.MMTouchJoystick
enum  MaxRangeModes { MaxRangeModes.Distance, MaxRangeModes.DistanceToTransform }
 
- Properties inherited from MoreMountains.Tools.MMTouchJoystick
float? ComputedMaxRange [get]
 
virtual RenderMode ParentCanvasRenderMode [get, protected set]
 the render mode of the parent canvas this stick is on More...
 

Detailed Description

Add this component to a UI rectangle and it'll act as a detection zone for a follower joystick. Note that this component extends the MMTouchJoystick class so you don't need to add another joystick to it. It's both the detection zone and the stick itself.

Member Function Documentation

◆ ClampToBounds()

override void MoreMountains.Tools.MMTouchFollowerJoystick.ClampToBounds ( )
protectedvirtual

We don't clamp the stick anymore

Reimplemented from MoreMountains.Tools.MMTouchJoystick.

◆ ComputeJoystickValue()

virtual void MoreMountains.Tools.MMTouchFollowerJoystick.ComputeJoystickValue ( )
protectedvirtual

Determines the value of the joystick by computing the

◆ ConstrainBackground()

virtual void MoreMountains.Tools.MMTouchFollowerJoystick.ConstrainBackground ( )
protectedvirtual

Clamps the background inside the inner rect

◆ CreateInnerRect()

virtual void MoreMountains.Tools.MMTouchFollowerJoystick.CreateInnerRect ( )
protectedvirtual

Creates a constraining inner rect

◆ HandleMovementInterpolation()

virtual void MoreMountains.Tools.MMTouchFollowerJoystick.HandleMovementInterpolation ( )
protectedvirtual

Handles the movement of the background relative to the knob

◆ Initialize()

override void MoreMountains.Tools.MMTouchFollowerJoystick.Initialize ( )
virtual

On initialize, we set our knob transform

Reimplemented from MoreMountains.Tools.MMTouchJoystick.

◆ OnDrag()

override void MoreMountains.Tools.MMTouchFollowerJoystick.OnDrag ( PointerEventData  eventData)
virtual

On drag, we adjust our target and constrain our background

Parameters
eventData

Reimplemented from MoreMountains.Tools.MMTouchJoystick.

◆ OnPointerDown()

override void MoreMountains.Tools.MMTouchFollowerJoystick.OnPointerDown ( PointerEventData  data)
virtual

When the zone is pressed, we move our joystick accordingly

Parameters
dataData.

Reimplemented from MoreMountains.Tools.MMTouchJoystick.

◆ OnPointerUp()

override void MoreMountains.Tools.MMTouchFollowerJoystick.OnPointerUp ( PointerEventData  data)
virtual

On pointer up we reset our joystick

Parameters
data

Reimplemented from MoreMountains.Tools.MMTouchJoystick.

◆ Start()

override void MoreMountains.Tools.MMTouchFollowerJoystick.Start ( )
protectedvirtual

On Start, we instantiate our joystick's image if there's one

Reimplemented from MoreMountains.Tools.MMTouchJoystick.

◆ Update()

override void MoreMountains.Tools.MMTouchFollowerJoystick.Update ( )
protectedvirtual

On update, we handle movement interpolation

Reimplemented from MoreMountains.Tools.MMTouchJoystick.

Member Data Documentation

◆ _backgroundPositionTarget

Vector3 MoreMountains.Tools.MMTouchFollowerJoystick._backgroundPositionTarget
protected

◆ _backgroundRectTransform

RectTransform MoreMountains.Tools.MMTouchFollowerJoystick._backgroundRectTransform
protected

◆ _initialPosition

Vector3 MoreMountains.Tools.MMTouchFollowerJoystick._initialPosition
protected

◆ _innerRectCorners

Vector3 [] MoreMountains.Tools.MMTouchFollowerJoystick._innerRectCorners = new Vector3[4]
protected

◆ _innerRectTransformBottomLeft

Vector3 MoreMountains.Tools.MMTouchFollowerJoystick._innerRectTransformBottomLeft
protected

◆ _innerRectTransformBottomRight

Vector3 MoreMountains.Tools.MMTouchFollowerJoystick._innerRectTransformBottomRight
protected

◆ _innerRectTransformTopLeft

Vector3 MoreMountains.Tools.MMTouchFollowerJoystick._innerRectTransformTopLeft
protected

◆ _innerRectTransformTopRight

Vector3 MoreMountains.Tools.MMTouchFollowerJoystick._innerRectTransformTopRight
protected

◆ _newBackgroundPosition

Vector3 MoreMountains.Tools.MMTouchFollowerJoystick._newBackgroundPosition
protected

◆ _newPosition

Vector3 MoreMountains.Tools.MMTouchFollowerJoystick._newPosition
protected

◆ _rectTransform

RectTransform MoreMountains.Tools.MMTouchFollowerJoystick._rectTransform
protected

◆ _springVelocity

Vector3 MoreMountains.Tools.MMTouchFollowerJoystick._springVelocity
protected

◆ BackgroundCanvasGroup

CanvasGroup MoreMountains.Tools.MMTouchFollowerJoystick.BackgroundCanvasGroup

the canvas group to use as the joystick's background

◆ BackgroundConstraintPaddingBottom

float MoreMountains.Tools.MMTouchFollowerJoystick.BackgroundConstraintPaddingBottom

the bottom padding to apply to the background constraint

◆ BackgroundConstraintPaddingLeft

float MoreMountains.Tools.MMTouchFollowerJoystick.BackgroundConstraintPaddingLeft

the left padding to apply to the background constraint

◆ BackgroundConstraintPaddingRight

float MoreMountains.Tools.MMTouchFollowerJoystick.BackgroundConstraintPaddingRight

the right padding to apply to the background constraint

◆ BackgroundConstraintPaddingTop

float MoreMountains.Tools.MMTouchFollowerJoystick.BackgroundConstraintPaddingTop

the top padding to apply to the background constraint

◆ BackgroundConstraintRectTransform

RectTransform MoreMountains.Tools.MMTouchFollowerJoystick.BackgroundConstraintRectTransform

the rect to consider as a background constraint zone, if left empty, will be auto created

◆ InterpolateFollowMovement

bool MoreMountains.Tools.MMTouchFollowerJoystick.InterpolateFollowMovement = false

if this is true, the background will follow its target with interpolation, otherwise it'll be instant movement

◆ InterpolateFollowMovementSpeed

float MoreMountains.Tools.MMTouchFollowerJoystick.InterpolateFollowMovementSpeed = 0.3f

if in interpolate mode, this defines the speed at which the backgrounds follows the knob

◆ KnobCanvasGroup

CanvasGroup MoreMountains.Tools.MMTouchFollowerJoystick.KnobCanvasGroup

the canvas group to use as the joystick's knob - the part that moves under your thumb

◆ ResetPositionToInitialOnRelease

bool MoreMountains.Tools.MMTouchFollowerJoystick.ResetPositionToInitialOnRelease = false

if this is true, the joystick will return back to its initial position when released

◆ ShouldConstrainBackground

bool MoreMountains.Tools.MMTouchFollowerJoystick.ShouldConstrainBackground = true

if this is true, the joystick won't be able to travel beyond the bounds of the top level canvas

◆ SpringDamping

float MoreMountains.Tools.MMTouchFollowerJoystick.SpringDamping = 0.6f

when in SpringFollowInterpolation mode, the amount of damping to apply to the spring

◆ SpringFollowInterpolation

bool MoreMountains.Tools.MMTouchFollowerJoystick.SpringFollowInterpolation = false

whether or not to add a spring to the interpolation of the background movement

◆ SpringFrequency

float MoreMountains.Tools.MMTouchFollowerJoystick.SpringFrequency = 4f

when in SpringFollowInterpolation mode, the frequency to apply to the spring


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