2D Toolkit Forum

2D Toolkit => Support => Topic started by: griden on January 25, 2014, 06:50:03 pm

Title: How to get standard Input touches for UIItem's?
Post by: griden 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 (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..
Title: Re: How to get standard Input touches for UIItem's?
Post by: unikronsoftware 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.
Title: Re: How to get standard Input touches for UIItem's?
Post by: play-i on April 21, 2014, 05:00:48 pm
any word on this ?

Title: Re: How to get standard Input touches for UIItem's?
Post by: unikronsoftware 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