Hello Guest

Author Topic: How to get standard Input touches for UIItem's?  (Read 3725 times)

griden

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 15
    • View Profile
How to get standard Input touches for UIItem's?
« on: January 25, 2014, 06:50:03 pm »
So I want to control the game character's movement with a simple two-directional pad - just two onscreen arrow elements/buttons next to each other. Tried the demo UI button examples, but the available events don't satisfy my needs unfortunately. The user should be able to slide between the two sprites without lifting her finger and the OnDown event doesn't get fired in this case. Also, it's a one time event and I need to execute some code for as long as the screen is being touched.

It would be enough if I can just get the standard unity Input touches (http://docs.unity3d.com/Documentation/ScriptReference/Input.GetTouch.html) that are applied over the sprite colliders (or just the sprites), so if you could give me some directions how to do that, I should be ok. Of course, any alternative ideas are welcome. Thanks.

PS: I saw the regular way to create such control element in Unity is by using GUITexture, but was wondering If I can utilise some of the TK2D features instead..
« Last Edit: January 25, 2014, 06:52:13 pm by griden »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: How to get standard Input touches for UIItem's?
« Reply #1 on: January 25, 2014, 11:17:39 pm »
If its a one off and you're not bothered about interacting with the rest of the UI system, then you could just use Input.touches and check if the button is inside the screen rect of your sprite. That should be pretty straightforward to handle in that case. This has been requested a few times so I'll add it to the roadmap trello.

play-i

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: How to get standard Input touches for UIItem's?
« Reply #2 on: April 21, 2014, 05:00:48 pm »
any word on this ?


unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: How to get standard Input touches for UIItem's?
« Reply #3 on: April 22, 2014, 03:08:13 pm »
Hmmm I couldn't find it on the roadmap so I've added it here -
https://trello.com/c/mx1WNgiy/63-a-way-to-capture-unoccluded-clicks