This is my c# script , i want to limit game object transform scale.
void Update () {
int fingersOnScreen=0;
float scaleFactor=0.0f;
foreach (Touch touch in Input.touches) {
fingersOnScreen++; //Count fingers (or rather touches) on screen as you iterate through all screen touches.
Debug.Log("1");
//You need two fingers on screen to pinch.
if(fingersOnScreen == 2){
//First set the initial distance between fingers so you can compare.
if(touch.phase == TouchPhase.Began){
initialFingersDistance = Vector2.Distance(Input.touches[0].position, Input.touches[1].position);
t.text =transform.localScale.x.ToString();
initialScale = transform.localScale;
}
else{
float currentFingersDistance = Vector2.Distance(Input.touches[0].position, Input.touches[1].position);
scaleFactor = currentFingersDistance / initialFingersDistance;
transform.localScale = initialScale * scaleFactor;
}
}
}