I'm working on implementing a click-and-drag or swipe style function in my Unity game. Recently it started ignoring my touch input, and after adding the following code to my GameController I found out why:
void Update () {
Touch[] touches = Input.touches;
Debug.Log (Input.touchCount);
for (int i = 0; i < touches.Length; i++) {
Touch touch = touches [i];
Debug.Log (touch.phase.ToString ());
Debug.Log ("Raw Position Touch(" + i + ")| X: " + touch.rawPosition.x.ToString() + " Y: " + touch.rawPosition.y.ToString());
}
}
which produces the following output at this exact position every frame:
1
Stationary
Raw Position Touch(0)| X: 647.7088 Y: 92.50534
If I then touch the screen it will of course also show an appropriate Raw Position for my finger. Ex:
2
Stationary
Raw Position Touch(0)| X: 647.7088 Y: 92.5034
Began
Raw Position Touch(1)| X: 526.8154 Y: 307.6912
This scared the hell out me. I figured that I had probably broken my touchscreen. I'm programming on a Win 10 laptop with touchscreen capability, which is really nice for testing mobile apps, and I figured I'd probably busted it and I had a phantom touch stuck there forever. However to test that I went into the device manager and disabled the touchscreen and it's still showing the same touch every frame.
Is it possible that I'm somehow instantiating a touch event elsewhere in my code? if so what would that code look like?