I have a GameObject in the scene with only one component that executes the following code in the Update method:
Debug.Log(Input.touchCount);
When I enter play mode and hold the left mouse button, 1 is printed to the console as expected then after a little while (1 to 2 seconds), 0 starts printing as if there were no touches even though I’m still holding down the left mouse button.
I’m using Unity 2021.2.17f1
Check the device simulator settings to map mouse clicks to touches.
There’s mouse clicks
There’s touches
And not only that but by default Input will map touches (on device) to mouse based on this:
BUT… all the above is inside Unity, far from the device simulator.
What you report seems to be purely from the simulator, as normally clicking the mouse will NOT give you touches at all, only the other way around.
Where can I find these settings?
What do you mean by this? When I press and hold the left mouse button inside the device simulator it results in Input.touchCount
printing 1 as excepted for a short while.
I would assume in the device simulator. I’ve never used it; we only test in editor or on actual hardware devices.
Unless there’s something new inside Unity, this will NOT normally happen if you make a PC build and click the mouse. That’s what I point out in the above blurb: the simulator must be providing this mouse-to-touch mapping. Unity ONLY provides touch to mouse.
@Kurt-Dekker ah, I guess you misunderstood. I’m indeed using the device simulator inside the editor as it is an editor-only thing. I never mentioned building or testing in a standalone app. This is all inside of the editor.
And no, there are no settings. Only a control panel that allows you to change the device language.
Could you solve this? Currently happening to me too…
Also after the touchCount goes to 0 while still holding the mouse button the End and Cancelled touch phase never triggers.
Unity version: 2022.1.24f