Author Topic: Unity 5 and Windows touch screens - OnDoubleClick() not being called  (Read 10449 times)

MigrantP

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 1
  • Posts: 22
    • View Profile
Since updating to Unity 5, we've been having an input issue with Windows touch screens. OnDoubleClick() does not get called by NGUI in our scripts when you use the touch screen, but it does get called when you use a mouse. OnClick() seems to work normally.

The Unity update notes say: "Standalone and webplayer: Input subsystem processes touch messages via WM_TOUCH. Previously it worked with Windows-simulated mouse events."

We updated to NGUI 3.8.2 but the problem remains. Is there something we can set in NGUI to fix this behaviour? Thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Unity 5 and Windows touch screens - OnDoubleClick() not being called
« Reply #1 on: April 16, 2015, 07:32:56 AM »
Each new touch has a new touch ID. First one is 1, second is 2, third is 3, etc. Double-click only works if the same ID can be matched up: ie touch ID #1 is followed by the same touch ID #1 within a quarter second of the first one. That's a double-click.

Separate touches = no double clicks/taps.

You can try to disable multi-touch, it may help -- but the best way would be to do your own logic for double-taps.

MigrantP

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 1
  • Posts: 22
    • View Profile
Re: Unity 5 and Windows touch screens - OnDoubleClick() not being called
« Reply #2 on: April 16, 2015, 07:43:03 AM »
Multitouch is already disabled. The same touch ID is coming in, but the clickTime property of the objects is not being set properly somewhere in the NGUI code. I think it may be because it's being handled as a touch UI, but tapCount is always 1 (unlike iOS/Android). NGUI's check for double click always fails no matter how fast you tap.

I ended up working around it and putting in my own double click handling for this one case.

I also noticed that the "right click" touch input (tap and hold) on Windows touch screens does not work; NGUI does not seem to see it at all.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Unity 5 and Windows touch screens - OnDoubleClick() not being called
« Reply #3 on: April 16, 2015, 07:45:27 AM »
Press and hold is a gesture, and NGUI doesn't do gesture recognition. It's really trivial to add however.
  1. void OnPress (bool isPressed)
  2. {
  3.     if (isPressed) Invoke("Hold", 0.5f);
  4.     else CancelInvoke("Hold");
  5. }
  6.  
  7. void Hold () { Debug.Log("Press and hold!"); }

MigrantP

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 1
  • Posts: 22
    • View Profile
Re: Unity 5 and Windows touch screens - OnDoubleClick() not being called
« Reply #4 on: April 16, 2015, 07:48:26 AM »
I know, but what I'm talking about is a little different. On Windows 8 if you touch and hold, it sends a right click to the program instead. At least, that's what happens in every other program, including ones that don't know about touch at all. When I do this gesture, it seems that NGUI does not report a touch at all.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Unity 5 and Windows touch screens - OnDoubleClick() not being called
« Reply #5 on: April 16, 2015, 08:26:43 AM »
NGUI just goes by what Unity tells it happened -- via Input.GetTouch by default.

For Win8 and Win7 I strongly advise using TouchScript: http://www.tasharen.com/forum/index.php?topic=4984.msg56678#msg56678