minimum and maximum position for sides of a camera

I am making a side scrolling game and would like to set minimum and maximum x and y values for the main camera. The camera is positioned at the player if it is inside the range otherwise it is positioned on the min or max of the axis. I have tried to use ScreenToWorldPoint to get the resolution of the screen to world units like so:

public void SetRange ( Vector3 newMin, Vector3 newMax )
	{
		Vector3 Edge = camera.ScreenToWorldPoint(new Vector3 (Screen.width / 2 , Screen.height / 2)); 
		Min = new Vector2 ( newMin.x + Edge.x, newMin.y - Edge.y );
		Max = new Vector2 ( newMax.x - Edge.x, newMax.y + Edge.y );
	}

newMin and newMax contain the positions of the corners of the map for the sides, however, this does not seem to work as it seems to be changing when the camera moves. Does anyone know how the min and max can be for the actual camera not the sides?

Hi, you can use Mathf.Clamp(), by that you can clamp value and it will not go under or more your given borders.

private float a = 2;

private void Update(){
    a = Mathf.Clamp(a, 0, 10); //a will always be from 0 to 10
}