TopDown Engine
v3.6
|
Joystick input class. In charge of the behaviour of the joystick mobile touch input. Bind its actions from the inspector Handles mouse and multi touch More...
Public Types | |
enum | MaxRangeModes { MaxRangeModes.Distance, MaxRangeModes.DistanceToTransform } |
Public Member Functions | |
virtual void | Initialize () |
Initializes the various parts of the stick More... | |
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 | OnDrag (PointerEventData eventData) |
Handles dragging of the joystick More... | |
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... | |
virtual void | OnPointerUp (PointerEventData data) |
What happens when the stick is released (even if no drag happened) More... | |
virtual void | OnPointerDown (PointerEventData data) |
What happens when the stick is pressed for the first time More... | |
Public Attributes | |
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 | |
virtual void | Start () |
On Start we initialize our stick More... | |
virtual void | Update () |
On Update we check for an orientation change if needed, and send our input values. More... | |
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 void | ClampToBounds () |
Clamps the stick to the specified range 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 | |
Vector2 | _neutralPosition |
Vector2 | _newTargetPosition |
Vector3 | _newJoystickPosition |
float | _initialZPosition |
float | _targetOpacity |
CanvasGroup | _canvasGroup |
float | _initialOpacity |
Transform | _knobTransform |
bool | _rotatingIndicatorIsNotNull = false |
float | _maxRangeTransformDistance |
Properties | |
float? | ComputedMaxRange [get] |
virtual RenderMode | ParentCanvasRenderMode [get, protected set] |
the render mode of the parent canvas this stick is on More... | |
Joystick input class. In charge of the behaviour of the joystick mobile touch input. Bind its actions from the inspector Handles mouse and multi touch
|
protectedvirtual |
Clamps the stick to the specified range
Reimplemented in MoreMountains.Tools.MMTouchFollowerJoystick.
|
protectedvirtual |
Converts a position to world position
position |
|
protectedvirtual |
We compute the axis value from the interval between neutral position, current stick position (vectorPosition) and max range
vectorPosition | stick position. |
|
protectedvirtual |
Changes or interpolates the opacity of the knob
|
virtual |
Initializes the various parts of the stick
Exception |
Reimplemented in MoreMountains.Tools.MMTouchFollowerJoystick, and MoreMountains.Tools.MMTouchRepositionableJoystick.
|
virtual |
Handles dragging of the joystick
Reimplemented in MoreMountains.Tools.MMTouchFollowerJoystick.
|
protectedvirtual |
On enable, we initialize our stick
|
virtual |
What happens when the stick stops being dragged
|
virtual |
What happens when the stick is pressed for the first time
data |
Reimplemented in MoreMountains.Tools.MMTouchFollowerJoystick, and MoreMountains.Tools.MMTouchRepositionableJoystick.
|
virtual |
What happens when the stick is released (even if no drag happened)
data |
Reimplemented in MoreMountains.Tools.MMTouchRepositionableJoystick, and MoreMountains.Tools.MMTouchFollowerJoystick.
|
virtual |
This method is used to compute the max range distance when in DistanceToTransform mode
|
virtual |
Resets the stick's position and values
|
protectedvirtual |
Rotates an indicator to match the rotation of the stick
|
virtual |
Assigns a new transform as the joystick knob
newTransform |
|
virtual |
Sets the neutral position of the joystick
|
virtual |
|
protectedvirtual |
On Start we initialize our stick
Reimplemented in MoreMountains.Tools.MMTouchFollowerJoystick, and MoreMountains.Tools.MMTouchRepositionableJoystick.
|
protectedvirtual |
On Update we check for an orientation change if needed, and send our input values.
Reimplemented in MoreMountains.Tools.MMTouchFollowerJoystick.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
bool MoreMountains.Tools.MMTouchJoystick.DrawGizmos = true |
whether or not to draw gizmos associated to this stick
bool MoreMountains.Tools.MMTouchJoystick.HorizontalAxisEnabled = true |
Is horizontal axis allowed.
bool MoreMountains.Tools.MMTouchJoystick.InterpolateOpacity = true |
whether or not to interpolate opacity changes on the knob's canvas group
float MoreMountains.Tools.MMTouchJoystick.InterpolateOpacitySpeed = 1f |
the speed at which to interpolate opacity
JoystickFloatEvent MoreMountains.Tools.MMTouchJoystick.JoystickMagnitudeValue |
JoystickEvent MoreMountains.Tools.MMTouchJoystick.JoystickNormalizedValue |
An event to use the normalized value of the joystick.
JoystickEvent MoreMountains.Tools.MMTouchJoystick.JoystickValue |
An event to use the raw value of the joystick.
float MoreMountains.Tools.MMTouchJoystick.Magnitude |
the magnitude of the stick's vector
float MoreMountains.Tools.MMTouchJoystick.MaxRange = 1.5f |
The MaxRange is the maximum distance from its initial center position you can drag the joystick to.
MaxRangeModes MoreMountains.Tools.MMTouchJoystick.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
Transform MoreMountains.Tools.MMTouchJoystick.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.
Vector2 MoreMountains.Tools.MMTouchJoystick.NormalizedValue |
the normalized value of the joystick
UnityEvent MoreMountains.Tools.MMTouchJoystick.OnDragEvent |
An event triggered when dragging the stick.
UnityEvent MoreMountains.Tools.MMTouchJoystick.OnPointerDownEvent |
An event triggered when tapping the joystick for the first time.
UnityEvent MoreMountains.Tools.MMTouchJoystick.OnPointerUpEvent |
An event triggered when releasing the stick.
float MoreMountains.Tools.MMTouchJoystick.PressedOpacity = 0.5f |
the new opacity to apply to the canvas group when the button is pressed
Vector2 MoreMountains.Tools.MMTouchJoystick.RawValue |
the raw value of the joystick, from 0 to 1 on each axis
Transform MoreMountains.Tools.MMTouchJoystick.RotatingIndicator |
an object you can rotate to show the direction of the joystick. Will only be visible if the movement is above a threshold
float MoreMountains.Tools.MMTouchJoystick.RotatingIndicatorThreshold = 0.1f |
the threshold above which the rotating indicator will appear
Camera MoreMountains.Tools.MMTouchJoystick.TargetCamera |
The camera to use as the reference for any ScreenToWorldPoint computations.
bool MoreMountains.Tools.MMTouchJoystick.VerticalAxisEnabled = true |
Is vertical axis allowed.
|
get |
|
getprotected set |
the render mode of the parent canvas this stick is on