var screenRect = new Rect(0,0, Screen.width, Screen.height);if(!screenRect.Contains(Input.mousePosition)){ // мышь вышла за пределы}