Hello All From 3 days I am fighting with configure my two buttons to work them on mobile phone. What I need, is simply when you press button left, then do something, when relase- stop doing this. This is my code for one of the buttons: Code (CSharp): public class ButtonB : MonoBehaviour { public bool buttonB = false; void OnMouseDown() { Debug.Log("ENGINE B PRESSED"); buttonB = true; } void OnMouseUp() { Debug.Log("ENGINE B UNPRESSED"); buttonB = false; } It works, but I can't press both buttons at a same time. I know that I should use GetTouch, but I am trying from like a 3 days and still don't know how it work! Can anyone help me, please? Thanks for any ideas!
You solved your issue with saying you need to take touch. Mouse Button is there only once afaik. You can script yourself a fakeTouch that gets generated on mouseclick and release all at the last mouseup, better try to use remote or a real device build.
Multi touch works fine, but there's known bug with it and unity remote. If you're using unity remote, try to test on device without it. And I suggest you switch to using IPointerUpHandler, IPointerDownHandler interfaces for handling input events because it has a parameter wich contains extended event data.
This worked for me: Code (CSharp): if (Input.touchCount > 0) { for (int i = 0; i < Input.touchCount; i++) if (Input.GetTouch(i).position.x < ScreenWidth / 2) { if (Input.GetTouch(i).phase == TouchPhase.Began) { Debug.Log("ENGINE A PRESSED"); buttonA = true; } else if (Input.GetTouch(i).phase == TouchPhase.Ended) { Debug.Log("ENGINE A unPRESSED"); buttonA = false; } } } Now I am just thinking is there any way to draw circle on a touched place and remove it when touch end?