Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: romeo_ftv on March 11, 2014, 01:53:42 PM

Title: Bug with UICamera.ProcessTouch
Post by: romeo_ftv on March 11, 2014, 01:53:42 PM
  1. public void ProcessTouch (bool pressed, bool unpressed)
  2. {
  3. ...
  4. // If the touch should consider clicks, send out an OnClick notification
  5.                                         if (currentTouch.clickNotification != ClickNotification.None)
  6.                                         {
  7.                                                 float time = RealTime.time;
  8.  
  9.                                                 Notify(currentTouch.pressed, "OnClick", null); <<<<< Sometimes this action calls OnApplicationPause, then currentTouch becomes null
  10.  
  11.                                                 if (currentTouch.clickTime + 0.35f > time) <<<<< and crash!!!
  12.                                                 {
  13.                                                         Notify(currentTouch.pressed, "OnDoubleClick", null);
  14.                                                 }
  15.                                                 currentTouch.clickTime = time;
  16.                                         }
  17. ...
  18. }
  19.  
Title: Re: Bug with UICamera.ProcessTouch
Post by: ArenMook on March 11, 2014, 04:54:21 PM
This OnApplicationPause will keep the current touch:
  1.         void OnApplicationPause ()
  2.         {
  3.                 MouseOrTouch prev = currentTouch;
  4.  
  5.                 if (useTouch)
  6.                 {
  7.                         BetterList<int> ids = new BetterList<int>();
  8.  
  9.                         foreach (KeyValuePair<int, MouseOrTouch> pair in mTouches)
  10.                         {
  11.                                 if (pair.Value != null && pair.Value.pressed)
  12.                                 {
  13.                                         currentTouch = pair.Value;
  14.                                         currentTouchID = pair.Key;
  15.                                         currentScheme = ControlScheme.Touch;
  16.                                         currentTouch.clickNotification = ClickNotification.None;
  17.                                         ProcessTouch(false, true);
  18.                                         ids.Add(currentTouchID);
  19.                                 }
  20.                         }
  21.  
  22.                         for (int i = 0; i < ids.size; ++i)
  23.                                 RemoveTouch(ids[i]);
  24.                 }
  25.  
  26.                 if (useMouse)
  27.                 {
  28.                         for (int i = 0; i < 3; ++i)
  29.                         {
  30.                                 if (mMouse[i].pressed)
  31.                                 {
  32.                                         currentTouch = mMouse[i];
  33.                                         currentTouchID = -1 - i;
  34.                                         currentKey = KeyCode.Mouse0 + i;
  35.                                         currentScheme = ControlScheme.Mouse;
  36.                                         currentTouch.clickNotification = ClickNotification.None;
  37.                                         ProcessTouch(false, true);
  38.                                 }
  39.                         }
  40.                 }
  41.  
  42.                 if (useController)
  43.                 {
  44.                         if (controller.pressed)
  45.                         {
  46.                                 currentTouch = controller;
  47.                                 currentTouchID = -100;
  48.                                 currentScheme = ControlScheme.Controller;
  49.                                 currentTouch.last = currentTouch.current;
  50.                                 currentTouch.current = mCurrentSelection;
  51.                                 currentTouch.clickNotification = ClickNotification.None;
  52.                                 ProcessTouch(false, true);
  53.                                 currentTouch.last = null;
  54.                         }
  55.                 }
  56.                 currentTouch = prev;
  57.         }
Title: Re: Bug with UICamera.ProcessTouch
Post by: avrilfeng on February 22, 2016, 03:45:16 AM
hey guys. i suffer this crash too. but i do not know where the code need to add, the UICamera?
Title: Re: Bug with UICamera.ProcessTouch
Post by: avrilfeng on February 22, 2016, 04:17:33 AM
hey! I have checked the UIcamera and found the code exist yet. my ngui is 3.8.0. the situation occured when i click uibutton to open another ui
Title: Re: Bug with UICamera.ProcessTouch
Post by: ArenMook on February 22, 2016, 07:09:32 PM
What crash? Nothing in NGUI will ever cause a crash. 3.8.0 is also extremely out of date, and only the latest version of NGUI is supported at all times.