public float max_x;
public float min_x;
public float max_y;
public float min_y;
void Update()
{
if (this.transform.position.x > max_x)
this.transform.position = new Vector3(max_x, this.transform.position.y, this.transform.position.z);
if (this.transform.position.x < min_x)
this.transform.position = new Vector3(min_x, this.transform.position.y, this.transform.position.z);
if (this.transform.position.y > max_y)
this.transform.position = new Vector3(this.transform.position.x, max_y, this.transform.position.z);
if (this.transform.position.y < min_y)
this.transform.position = new Vector3(this.transform.position.x, min_y, this.transform.position.z);
}