- Home /
How do i press multiple buttons at once in a single swipe
Hello,
I'm working on a lite piano android game trying to learn how to use unity, and i'm trying to make it so that i can press all of the keys in a single swipe of the screen, while having all of the keys animate as if they're being pressed.
I've currently got a setup of 8 buttons in a line, all of them using OnPointerDown to play an AudioSource when i tap on any of the buttons, and OnPointerEnter to play all of the sounds when i swipe across the buttons. The problem with the solution i'm using is that if i start my dragging motion from any of the buttons, the first one pressed will remain pressed down and the rest of them will not get highlighted. If instead i start the dragging motion from above the buttons, they all get highlighted accordingly.
Any hints for this? I've been searching for a few hours.
Thanks!
As an update, i've figured that i can: Set all of the button state colors to white, then set the CanvasRender.SetAlpha to 0.8 and thus get the "pressed" effect while sliding over, sounds and everything.
The only problem left now is that the first button pressed still remains with a set alpha of 0.8 upon moving the Pointer outside of the button boundary, as long as the finger is held down.
When you apply input use Raycast to detect the button and continue that when you're dragging. You'll be able to get the all button being pressed when you apply input as you're detecting it when you're swiping.
If you don't know how Raycast works , check this out:
http://docs.unity3d.com/ScriptReference/Physics.Raycast.html
Your answer
Follow this Question
Related Questions
Multi touch support for Android devices 0 Answers
Two player touch screen 1 Answer
Swipe and Joystick Together on Mobile 0 Answers
Do On swipe finger? 1 Answer
Android wear swipe to dismiss 0 Answers