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

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:
    64
    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:
    64
    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:
    64
    Allright thanks