Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Device Simulator Touches Expire?

Discussion in 'Editor & General Support' started by WinterboltGames, Mar 25, 2022.

  1. WinterboltGames

    WinterboltGames

    Joined:
    Jul 27, 2016
    Posts:
    259
    I have a GameObject in the scene with only one component that executes the following code in the Update method:
    Code (CSharp):
    1. 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
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,514
    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:

    https://docs.unity3d.com/ScriptReference/Input-simulateMouseWithTouches.html

    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.
     
  3. WinterboltGames

    WinterboltGames

    Joined:
    Jul 27, 2016
    Posts:
    259
    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.
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,514
    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.
     
  5. WinterboltGames

    WinterboltGames

    Joined:
    Jul 27, 2016
    Posts:
    259
    @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.
     
  6. Menyus777

    Menyus777

    Joined:
    Jun 11, 2017
    Posts:
    30
    Could you solve this? Currently happening to me too...
     
  7. Menyus777

    Menyus777

    Joined:
    Jun 11, 2017
    Posts:
    30
    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