hi ,
i am trying to create a slider effect in game, the scene has 10 buttons(GUI.BUTTON) for every level respectively, what i want is when the user slides his finger on the screen vertically the buttons should move up and down depending upon the slide direction.
can someone please tel me how to go about it ,…
hi there here is a modified script for moving objects on touch. Maybe you can alter it to detect your buttons.
private var h : float;
private var v : float;
private var horizontalSpeed : float = 0.5;
private var verticalSpeed : float = 0.5;
function Update ()
{
if (Input.touchCount == 1)
{
var touch : Touch = Input.GetTouch(0);
if( Input.GetMouseButtonDown(0)) {
var ray : Ray = Camera.main.ScreenPointToRay
(Input.mousePosition);
var hit : RaycastHit;
if (collider.Raycast (ray, hit, 100.0))
if (touch.phase == TouchPhase.Moved)
{
h = horizontalSpeed * touch.deltaPosition.x;
transform.Translate(0,0,-h, Space.World);
v = verticalSpeed * touch.deltaPosition.y;
transform.Translate(0,0,v, Space.World);
}
}
}
}