Inverted mouselook when upside down.

I am having some issues with my mouselook, in my game you can rotate in 360 degrees in all directions. The issue is that when you go upside down the mouse is inverted which makes sense but does anyone know of a solution to this? The question has been asked before but there was no functional answer.

using if(ZRotation > 180){
invert mouse code
}
does not work instead the camera just does not rotate fully.

Thank You

Try

if ( transform.up.y < 0 ) { invert mouse input }