Support => NGUI 3 Support => Topic started by: whydoidoit on June 28, 2012, 11:45:22 AM
Title: Missing Touch Events
Post by: whydoidoit on June 28, 2012, 11:45:22 AM
Hi - I'm getting a few problems with button presses when my frame rate drops on IOS due to extra network players arriving and configuring. It's happening in the NGUI stuff and also elsewhere on my game. I've been on to Unity Support and they've pointed out that Began events are not guaranteed to arrive in situations where the main loop doesn't run fast enough.
They're suggesting is that the Began event will be overwritten by a Moved or a Stationery before the game gets to see it. I see UICamera uses Began - so I'm going to modify it to look for a moved etc on a finger not currently tracked and have that do the pressed action - just wondering if you had anything else that might already do this?
Title: Re: Missing Touch Events
Post by: ArenMook on June 29, 2012, 02:51:36 AM
Began events? Moved? Stationary? What?
Title: Re: Missing Touch Events
Post by: arihollander on July 11, 2012, 01:59:02 PM
I have no idea what "Began" events are, but I too am getting missed button presses in iOS.
Any ideas?
Title: Re: Missing Touch Events
Post by: PhilipC on July 11, 2012, 02:51:32 PM
I do have 1 idea but i cant test on iOS (dont have any devices) so this is a wild guess so it may not be correct.
Line 787 of UICamera looks like
bool pressed =(input.phase== TouchPhase.Began);
now from what whydoidoit say Unity Support said to do you need to also look at TouchPhase.Stationary and TouchPhase.Moved. The trick here is to only count stationary and moved as pressed = true once (easier said then done). I think some value of currentTouch will need to be watched to see if you should included stationary and moved but unsure which (if any).
If i come up with something more concrete i will post.
Title: Re: Missing Touch Events
Post by: reptilebeats on July 11, 2012, 05:35:06 PM
i havent had any problems with useing touch yet, but i dont use any scripts provided by ngui except from the panel, all my sprits are tested for hits from one script instead of sending a message
if i explain for people who dont know began events is the current touch of a finger on screen. so began is when the finger has began touching, stationary is when the finger is well it says it self. so in a script it may look like
var touch = Input.GetTouch;
if(touch.phase == TouchPhase.Began){ do something } and for multi touch just put into a loop to count each touch.
Title: Re: Missing Touch Events
Post by: arihollander on July 13, 2012, 12:42:48 PM
I tried making these changes to UICamera.cs and it seems to work thus far:
I modified the MouseOrTouch class (changes in blue):
public class MouseOrTouch { public Vector2 pos; // Current position of the mouse or touch event public Vector2 delta; // Delta since last update public Vector2 totalDelta; // Delta since the event started being tracked
public Camera pressedCam; // Camera that the OnPress(true) was fired with
public GameObject current; // The current game object under the touch or mouse public GameObject pressed; // The last game object to receive OnPress
public float clickTime = 0f; // The last time a click event was sent out
public bool isNew = true; //Allow for the possibility that MouseOrTouch is late to the party and missed a Began event
public ClickNotification clickNotification = ClickNotification.Always; }