Author Topic: UICamera.touchCount BUG? KeyNotFoundException  (Read 6860 times)

danfoo

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 93
    • View Profile
UICamera.touchCount BUG? KeyNotFoundException
« on: April 24, 2013, 08:33:13 AM »
Hi,

Calling UICamera.touchCount
  1. if(activeTouches != UICamera.touchCount)
results in an error on line 386 in UICamera.cs:
KeyNotFoundException: The given key was not present in the dictionary.
  1.         if (mTouches[i].pressed != null)

Please advise? Thanks!
//Daniel

danfoo

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 93
    • View Profile
Re: UICamera.touchCount BUG? KeyNotFoundException
« Reply #1 on: April 24, 2013, 08:36:20 AM »
I should probably add that this happens when only using touches in the editor (via Unityremote). After disabling mouse input in UICamera, the error started to occur.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: UICamera.touchCount BUG? KeyNotFoundException
« Reply #2 on: April 24, 2013, 11:09:59 AM »
Unity remote is crap; don't rely on it.

danfoo

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 93
    • View Profile
Re: UICamera.touchCount BUG? KeyNotFoundException
« Reply #3 on: April 26, 2013, 06:59:37 AM »
Unity remote is crap; don't rely on it.
Not really a constructive reply. I see you are a moderator. Does that mean I should consider your reply as one backed by Tasharen?

Unityremote is quite handy during UI testing, at least it was with our previous UI system. How else would you suggest we do fine-tuning? Build the project each time we tweak a value? You can't be serious.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UICamera.touchCount BUG? KeyNotFoundException
« Reply #4 on: April 26, 2013, 12:44:47 PM »
Unity remote sends both mouse and touch events from a single action, which messes with NGUI, which is why using it is not advised.

Change this:
  1. for (int i = 0; i < mTouches.Count; ++i)
  2.                                 if (mTouches[i].pressed != null)
  3.                                         ++count;
to this:
  1. foreach (KeyValuePair<int, MouseOrTouch> t in mTouches)
  2.                 if (t.Value.pressed != null)
  3.                     ++count;
« Last Edit: April 26, 2013, 01:04:58 PM by ArenMook »

Zapgun

  • Guest
Re: UICamera.touchCount BUG? KeyNotFoundException
« Reply #5 on: April 27, 2013, 03:42:39 PM »
I was having the same issue running my game under iOS and the XCode debugger, however this patch fixed it for me...were you planning on including it in an upcoming release?

- Zapgun

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UICamera.touchCount BUG? KeyNotFoundException
« Reply #6 on: April 27, 2013, 03:43:08 PM »
It's already in the Pro version, so yup.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: UICamera.touchCount BUG? KeyNotFoundException
« Reply #7 on: April 27, 2013, 07:19:46 PM »
No, my answers are not official support answers by Tasharen, I'm just helping out in here.

Unity remote is utterly useless in my opinion, but your mileage may vary.
Not really a constructive reply. I see you are a moderator. Does that mean I should consider your reply as one backed by Tasharen?

Unityremote is quite handy during UI testing, at least it was with our previous UI system. How else would you suggest we do fine-tuning? Build the project each time we tweak a value? You can't be serious.

danfoo

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 93
    • View Profile
Re: UICamera.touchCount BUG? KeyNotFoundException
« Reply #8 on: April 29, 2013, 10:03:57 AM »
It's already in the Pro version, so yup.
Thanks. Perhaps it's time to upgrade to pro...