Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Bug Device Simulator Touches Expire?

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

  1. WinterboltGames

    WinterboltGames

    Joined:
    Jul 27, 2016
    Posts:
    245
    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:
    31,149
    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:
    245
    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:
    31,149
    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:
    245
    @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.