Make GUI elements disappear

HI. I have a few GUI elements (two slider bars and a few buttons) onscreen which help me adjust the speed and position of a fly through camera, i am then recording the fly throughs with screen capture software. The problem is i would like the GUI elements to be invisible unless the mouse is over the screen. Can anybody help.??

well! check the position of the mouse and depending it's position set a variable (say showGUI) to true and false and then in your OnGUI check the variable to see if you should draw the gui or not in this frame.

void OnGUI ()
{
if (showGUI == true) { //show your gui and call them }
else {//don't do anything related to those GUI elements }
}
void Update ()
{
if (Input.mousePosition.y > Screen.height/2 ) //check any other condition that is suitable for you
{
showGUI = true;
}
else
showGUI = false;
}

Simple way:

Make a empty object with only GUIs, transform in a prefab, destroy to "hide" and instantiate to "show".

This is the code i used in the end

function Update(){

if (Input.mousePosition.y < Screen.height && Input.mousePosition.y > 0 && Input.mousePosition.x < Screen.width && Input.mousePosition.x > 0) //check to see if the mouse is over the Screen
{
showGUI = true;
}
else
{
showGUI = false;
}
function OnGUI(){

if (showGUI == true) {