I am stuck with an issue of moving the slider on android mobiles with finger touch event while developing pong game in unity 3D, though its working fine for pc.

This game is developed in 2D environment... please help me if anyone have available solution to this issue enter image description here

Actually I have developed this game for pc so I have code for the movement of slider accordingly as below:

var keyup:KeyCode;
var keydown:KeyCode;
var speed:float=1;

function Update () {
    else if(Input.GetKey(keydown))

But now i want to use this game for android mobiles.


1 Answer 1


You can create a script attached to the object you want to drag and adapt your code to work inside OnMouseDown() & OnMouseDrag()

  • \$\begingroup\$ Do OnMouseDown() & OnMouseDrag() will work for android mobile devices ?? \$\endgroup\$ Commented Jul 10, 2015 at 7:11
  • \$\begingroup\$ Yes they will work fine. Input.GetKeyDown(KeyCode.Mouse0) will also work for a single tap/touch event \$\endgroup\$ Commented Jul 10, 2015 at 12:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .