Author Topic: UICamera.cs dragCount throw exception in device  (Read 2019 times)

yuewah

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 180
    • View Profile
UICamera.cs dragCount throw exception in device
« on: August 19, 2013, 11:15:48 PM »
UICamera(Script)
Use Mouse = true
Use Touch = true
Allow Multi Touch = false
Sticky Press = false

KeyNotFoundException: The given key was not present in the dictionary.

at System.Collections.Generic.Dictionary`2[System.Int32,UICamera+MouseOrTouch].get_Item (Int32 key)
at UICamera.get_dragCount () [0x00009] in D:\MGR\Assets\External\NGUI\Scripts\UI\UICamera.cs:431

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UICamera.cs dragCount throw exception in device
« Reply #1 on: August 20, 2013, 01:50:08 PM »
It should be:
  1.         /// <summary>
  2.         /// Number of active touches from all sources.
  3.         /// </summary>
  4.  
  5.         static public int touchCount
  6.         {
  7.                 get
  8.                 {
  9.                         int count = 0;
  10.  
  11.                         foreach (KeyValuePair<int, MouseOrTouch> touch in mTouches)
  12.                                 if (touch.Value.pressed != null)
  13.                                         ++count;
  14.  
  15.                         for (int i = 0; i < mMouse.Length; ++i)
  16.                                 if (mMouse[i].pressed != null)
  17.                                         ++count;
  18.  
  19.                         if (mController.pressed != null)
  20.                                 ++count;
  21.  
  22.                         return count;
  23.                 }
  24.         }
  25.  
  26.         /// <summary>
  27.         /// Number of active drag events from all sources.
  28.         /// </summary>
  29.  
  30.         static public int dragCount
  31.         {
  32.                 get
  33.                 {
  34.                         int count = 0;
  35.  
  36.                         foreach (KeyValuePair<int, MouseOrTouch> touch in mTouches)
  37.                                 if (touch.Value.dragged != null)
  38.                                         ++count;
  39.  
  40.                         for (int i = 0; i < mMouse.Length; ++i)
  41.                                 if (mMouse[i].dragged != null)
  42.                                         ++count;
  43.  
  44.                         if (mController.dragged != null)
  45.                                 ++count;
  46.  
  47.                         return count;
  48.                 }
  49.         }

yuewah

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 180
    • View Profile
Re: UICamera.cs dragCount throw exception in device
« Reply #2 on: August 20, 2013, 08:57:21 PM »
Just tested on device, it works...thank a lot