Author Topic: Easy way to have access to all touches  (Read 2034 times)

sisso

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 46
    • View Profile
Easy way to have access to all touches
« on: April 16, 2013, 10:30:15 AM »
Hi,

There is some algorithms that is better to have access to all touches instead receive separate events.

Because I didn't found any easy way, I hacked UICamera with the following function:

EDITED > The code below didn't work in some situations in android. It is better to create  your own centralized input.

  1. static public MouseOrTouch[] GetTouches() {
  2.                 var list = new List<MouseOrTouch>();
  3.                 for (int i = 0; i < mMouse.Length; ++i)
  4.                         if (mMouse[i].pressed != null)
  5.                                 list.Add(mMouse[i]);
  6.  
  7.                 for (int i = 0; i < mTouches.Count; ++i)
  8.                         if (mTouches[i].pressed != null)
  9.                                 list.Add(mTouches[i]);
  10.                
  11.                 return list.ToArray();
  12.         }

Questions:

1) There is another way to access this information without change NGUI code?

2) This information could not be provided by I reason, so, I could have problem in use it in "Update"/"LateUpdate" methods?

3) We could have something like it in next release?

Thanks,
Sisso
« Last Edit: April 17, 2013, 12:51:13 PM by sisso »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Easy way to have access to all touches
« Reply #1 on: April 16, 2013, 02:22:06 PM »
Just use Input.touches. That's what NGUI uses as well. It just keeps additional information it needs, but that's internal and you shouldn't need it.

sisso

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 46
    • View Profile
Re: Easy way to have access to all touches
« Reply #2 on: April 16, 2013, 02:41:45 PM »
Thanks.

But I use from NGUI because mouse and touches are normalized. Between normalize by myself or hack ngui, I take the second one :P