Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. We are looking for feedback on the experimental Unity Safe Mode which is aiming to help you resolve compilation errors faster during project startup.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Input.GetMouseButton(0) as fast as touchevent when used on touchdevice?

Discussion in 'Scripting' started by celaeno, Jun 26, 2014.

  1. celaeno

    celaeno

    Joined:
    Jan 31, 2013
    Posts:
    54
    Hello,

    I'm using Input.GetMouseButton(0) for dragging an object on a touchdevice. Is this as fast as
    Input.GetTouch(0).phase == TouchPhase.Moved ?

    I know that OnMouseDrag is slower on touchdevices, but what about GetMouseButton(0) used on a touchdevice?

    Thanks
     
  2. GarthSmith

    GarthSmith

    Joined:
    Apr 26, 2012
    Posts:
    1,240
    Almost all the Input class stuff gets set before Update() is called. I would expect Input.GetMouseButton(0) to be true the same frame that Input.GetTouch(0).phase == TouchPhase.Began
     
  3. celaeno

    celaeno

    Joined:
    Jan 31, 2013
    Posts:
    54
    Thanks, I forgot tot ask input.mouseposition used on a touchdevice, is it as fast as input.gettouch(0).position?
     
  4. GarthSmith

    GarthSmith

    Joined:
    Apr 26, 2012
    Posts:
    1,240
    Yes. Those values are set before Update() runs. So you would see both of them get updated on the same frame.
     
  5. celaeno

    celaeno

    Joined:
    Jan 31, 2013
    Posts:
    54
    Allright thanks
     
unityunity