OnMouseDown for mobile in unity
bool dragBool;
//On PC (instead of)
void OnMouseDown() {
//The start
dragBool = true;
}
void OnMouseUp() {
//The Finish
dragBool = false;
}
//On mobile (do this)
void Update() {
if(Input.touchCount == 1) {
if(Input.GetTouch(0).phase == TouchPhase.Began)
dragBool = true;
else if(Input.GetTouch(0).phase == TouchPhase.Ended)
dragBool = false;
}
}
//When the dragBool is true it means the touch of the player starts
//And when is false it means it stops