- Home /
Question by
crazyKnight · Jun 30, 2011 at 01:13 PM ·
guiiosslider
how to create GUI slide effect ??
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 ,.....
Comment
Answer by gazza529 · May 31, 2013 at 10:19 AM
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);
}
}
}
}
Your answer
Follow this Question
Related Questions
Problem with centering text 1 Answer
iOS development and GUI for it 1 Answer
size of GUI pics too big 1 Answer
Issue with GUI.TextArea keyboard on iPhone 0 Answers
'MouseLook.sensitivityX' is inaccessible due to its protection level. 2 Answers