Prevent mouse look y from dropping underground

I’m having a problem because of my lack of understanding Euler Angles and all that stuff. Here is my code:

using UnityEngine;
using System.Collections;

public class LookY : MonoBehaviour {

	[SerializeField]
	float _sensivity = 5.0f;

	float _mouseY = 0.0f;

	[SerializeField]
	public float _minimumHeight = 2;

	[SerializeField]
	GameObject _camera;

	void Start () {
	
	}
	

	void Update () {
		_mouseY = -Input.GetAxis ("Mouse Y");

		Vector3 rot = transform.localEulerAngles;
		rot.x += _mouseY * _sensivity;

		if (_camera.transform.position.y <= _minimumHeight && _mouseY < 0){
			rot.x = _minimumHeight + 1;
		}

		transform.localEulerAngles = rot;
	}
}

It is supposed to allow rotation up and down, but when the camera reaches ground level, it is not supposed to go any lower. Nevertheless, it doesn’t work. The camera doesn’t go below ground level but dramatically jumps up instead. Can someone help me? I don’t want to reset the camera automatically, but prevent it from going down further.

Hi again. I fixed it with this code:

using UnityEngine;
using System.Collections;

public class LookY : MonoBehaviour {

	[SerializeField]
	float _sensivity = 5.0f;

	float _mouseY = 0.0f;

	[SerializeField]
	public float _minimumHeight = 2;

	[SerializeField]
	GameObject _camera;

	void Start () {
	
	}
	

	void Update () {
		_mouseY = -Input.GetAxis ("Mouse Y");
		Debug.Log (transform.localEulerAngles.x);

		Vector3 rot = transform.localEulerAngles;


		if (_camera.transform.position.y >= _minimumHeight || _mouseY > 0){
			rot.x += _mouseY * _sensivity;
		}

		transform.localEulerAngles = rot;
	}
}

It checks if the camera is above the set height or if the person moves the mouse to look up. If one of those conditions is true, the camera is free to move.