Skip to main content

TouchScreenMenuBase.TouchInput

A protected class in Root.Township, the global namespace. Reach it through att-stubs' publicized assemblies or Harmony's AccessTools.

Tracks one fingertip against a touch screen menu: whether it is close, touching, and whether it swiped. Client side, one per finger.

Constructors​

MemberWhat it is
TouchInput(Transform fingerTip, Interactor interactor, float touchThreshold, float touchReleaseThreshold)Creates a TouchScreenMenuBase.TouchInput from fingerTip, interactor, touchThreshold, touchReleaseThreshold and minDistanceToRenderSquared.
TouchInput(Transform fingerTip, Interactor interactor, float touchThreshold, float touchReleaseThreshold, float minDistanceToRenderSquared)Creates a TouchScreenMenuBase.TouchInput from fingerTip, interactor, touchThreshold, touchReleaseThreshold and minDistanceToRenderSquared.

Fields​

7 private and internal fields
MemberWhat it is
private Transform fingerTipTransform of the fingertip being tracked.
private bool hasTouchedButtonSet by ButtonTouched; stops the current touch from also counting as a swipe.
private float minDistanceToRenderSquaredSquared distance from the canvas beyond which the finger counts as not close.
private float touchReleaseThresholdDepth the finger must come back past before a touch is released.
private Vector2 touchStartPositionScreen position where the current touch began, used to work out the swipe.
private float touchThresholdDepth into the screen at which a touch starts.
private bool wasLastAboveScreenWhether the finger was behind the screen plane last update, so a touch only starts when pressing in from the front.

Properties​

MemberWhat it is
bool BeganTouch { get; private set; }True only on the update where the finger first crossed the touch threshold.
float Distance { get; private set; }How far the fingertip is behind the screen plane, in screen space; 0 when in front.
Vector3 FingerTipPosition { get; private set; }World position of the fingertip at the last update.
Interactor Interactor { get; }The hand interactor this finger belongs to.
bool IsClose { get; private set; }True when the fingertip is within render distance of the screen.
bool IsTouching { get; private set; }True while the finger is pressed into the screen past the touch threshold.
Vector2? Swipe { get; private set; }Set for one update when a touch ends without hitting a button: the drag from start to end position. Otherwise null.
Vector2 TouchPosition { get; private set; }Fingertip position in the screen's local space.

Methods​

MemberWhat it is
void ButtonTouched()Marks that this touch hit a button, so releasing it doesn't count as a swipe.
void UpdateTouch(Vector3 canvasPosition, Matrix4x4 matrix)Updates position, closeness, touching state and swipe from the fingertip, the canvas position and the screen's matrix.

Used in​

Members of other types that take, return or hold a TouchInput: