Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: wom on November 10, 2013, 01:03:30 AM

Title: OnClick not firing via touch over unity remote?
Post by: wom on November 10, 2013, 01:03:30 AM
Reproduction:
- unity remote running on device
- device connected over USB with ADB
- play in Unity
- click mouse on widget in Unity game view: OnClick fires
- touch finger on widget on tablet showing game via Unity Remote: OnClick does not fire

Workaround:
- I can actually get NGUI to work normally by playing the game, then going into the UICamera in the hierarchy view and frobbing one of the UICamera checkboxes (Debug/Allow Multi Touch/Sticky Press). 
Toggling a checkbox only fixes the problem if you do it at play time (e.g. toggling debug during playtime makes it work, but if you set debug on before pressing play, it won't work until you toggle the checkbox).

Dev Environment:
NGUI 3.0.5
Unity 4.2.2f1
Windows 7 64bit

Test platform:
Nexus 7
Android 4.3
Unity Remote 1.2

Notes:
- problem began after installing NGUI 3.0.5 - can fix by regressing my project to previous version (which was using NGUI 3.0.2)
- OnClick fires fine when running on device properly (i.e. no Unity Remote)
- the touch input from unity remote appears to be coming across the wire: you can see when you hold the touch, NGUI does the "hold" animation, it just doesn't fire the click notification when you release the touch


Title: Re: OnClick not firing via touch over unity remote?
Post by: ArenMook on November 10, 2013, 07:11:22 AM
Unity Remote sends both touch and mouse events from a single action, which makes it difficult to tell what's actually going on. Currently if a touch event is detected, all mouse events get canceled.

I don't advise using Unity Remote at all.
Title: Re: OnClick not firing via touch over unity remote?
Post by: wom on November 11, 2013, 03:00:53 AM
Bummer. 
I think Unity Remote provides more value to me than keeping up to date with the latest versions of NGUI.
If you do get NGUI working with Remote again - please put a note about it in the latest version topic.

Title: Re: OnClick not firing via touch over unity remote?
Post by: ArenMook on November 11, 2013, 04:43:36 PM
You can modify the section that begins on line 894 of UICamera.cs to the following:
  1.                 if (useTouch)
  2.                 {
  3.                         // Process touch events first
  4.                         ProcessTouches();
  5.  
  6.                         // If we want to process mouse events, only do so if there are no active touch events,
  7.                         // otherwise there is going to be event duplication as Unity treats touch events as mouse events.
  8.                         if (useMouse && Input.touchCount == 0)
  9.                                 ProcessMouse();
  10.                 }
  11.                 else if (useMouse) ProcessMouse();