I needed the logic to camera tilting angle (axis x) in inspector.
I use this:
// .. in void Update() in an if statement, only when left mouse is pressed if( Input.GetMouseButton(0)) { ... }
// vertically mouse y delta to last frame
var fY = Input.GetAxis(InputAxis.MOUSE_Y);
var v = gcProfile.CameraTurnSpeedVertically * fY;
// make rotation
var rotation = new Vector3(-v, 0, 0);
var tt = target.transform;
tt.Rotate(rotation, Space.Self);
// limits for angle in tilt x axis, as seen in inspector
const int bottom = 45;
const int top = -90;
// convert transform to values, as seen in inspector
var eulerTiltX = TransformUtils.GetInspectorRotation(tt).x;
Debug.Log("local euler tilt (x): " + eulerTiltX + " <- " + fY);
// x (inspector angle for tilt angle)
// as long as try to rotate camera vertically in fY direction and the angle in inspector reaches limit ...
if (eulerTiltX > bottom) // && fY < 0 -- not really nessessary
{
// then: set inspector value to bottom boundary
TransformUtils.SetInspectorRotation(tt, new Vector3(bottom, 0, 0));
}
else if (eulerTiltX < top) // && fY > 0 -- not really nessessary
{
TransformUtils.SetInspectorRotation(tt, new Vector3(top, 0, 0));
}