- Home /
how i can change value By UI slider !!
I created an ui slider and i have touch script and sensetivity x , sensetivity Y Variables , and i want control in this variables by slider .
My script :
var sensitivityX = 13.5f;
var sensitivityY = 13.5f;
var invertX = true;
var invertY = true;
function Awake(){
sensitivityX = 5.5f;
sensitivityY = 5.5f;
}
// Update is called once per frame
function Update () {
if (Input.touches.Length > 0)
{
if (Input.touches[0].phase == TouchPhase.Moved)
{
var delta : Vector2 = Input.touches[0].deltaPosition;
var rotationZ = delta.x * sensitivityX * Time.deltaTime;
rotationZ = invertX ? rotationZ : rotationZ * -1;
var rotationX = delta.y * sensitivityY * Time.deltaTime;
rotationX = invertY ? rotationX : rotationX * -1;
transform.localEulerAngles += new Vector3(rotationX, rotationZ, 0);
}
}
}
Comment
Answer by DoTA_KAMIKADzE · Jun 20, 2015 at 03:58 PM
As OctoMan has pointed out for you - Slider.value returns current value of slider, you can set min/max value via Inspector or using minValue/maxValue. onValueChanged event will tell you when value has changed, or you can use it via Inspector as well, example of which you can find in Unity's UI examples.