Making GUI elements invisible

I need to make some GUI buttons invisible when no activity is detected from the user i.e. no mouse movement or keyboard input.

Is there a way to do this?

In your OnGUI function, you would just avoid the statements which would show the buttons, something like:

var activity : boolean = false;

function OnGUI()
{
  ... 

  if (!activity)
  {
    var pressed = GUI.Button("ok");
 ...

And it's up to you to set 'activity' true when you detect some activity. You could do this in the Update function by detecting key presses, mouse movement, mouse buttons, etc. and set to false when none are there, true if any are there. And I'd guess you'd want to put a bit of a delay on it too, perhaps half a second, such that the GUI doesn't flash as event do/don't happen.

Another way is to use GUIStyle.none as the style. This is useful when you use GUILayout as it will preserve the position of other elements.

Note also that in cases where you want to draw none of the elements, you are better off deactivating the entire script, not just skipping lines. OnGUI has expensive setup, even when it doesn't end up drawing anything.