limit transform class localScale

hi

i built in a zoom function to make an object bigger or smaller using this code

 if (GUI.RepeatButton(pos6, "zoom out")) // make object smaller
    {
    transform.localScale.x -= 0.0007;
    transform.localScale.y -= 0.0007;
    transform.localScale.z -= 0.0007;

 if (GUI.RepeatButton(pos5, "zoom in"))
  {
    transform.localScale.x += 0.0007; // make object bigger
    transform.localScale.y += 0.0007;
    transform.localScale.z += 0.0007; 
  }

Question:

is there a code to limit the the transform.?

greetz,

You would have to do it manually.

// C#

float Max = 1;
float Min = 0;

void Update()
{
     transform.localScale = new Vector3(
          Mathf.Clamp(transform.localScale.x, Min, Max),
          Mathf.Clamp(transform.localScale.y, Min, Max),
          Mathf.Clamp(transform.localScale.z, Min, Max)
     );
}

Something like that should do the trick.