On Mouse Down to trigger OnGUI function

How do I nest a function within another function? In other words, I’d like the GUI slider to appear when I call function OnMouseDown:

var slider : float=1;

function OnGUI () { 
	slider = GUI.HorizontalSlider( Rect(20,135,175,30), slider, 0.0, 1.0);
	renderer.material.color.a = slider;
}

I also tried to do:

var slider : float=1;

function OnGUI () { 
	if (Input.GetKeyDown("mouse 0")){
	slider = GUI.HorizontalSlider( Rect(20,135,175,30), slider, 0.0, 1.0);
	renderer.material.color.a = slider;
	}
}

but nothing happened when I pressed the LMB.

All I would do is go:

var slider : float=1;
var buttonPressed = false;

function Update(){
    if (Input.GetKey("mouse 0")){
        buttonPressed = true;
    }
}

function OnGUI () { 
    if (buttonPressed == true){
        slider = GUI.HorizontalSlider( Rect(20,135,175,30), slider, 0.0, 1.0);
        renderer.material.color.a = slider;
    }
}

This option would also allow you to be able to set the buttonPressed variable as false again if you wanted to in the future....

Hope this helps

-Grady

FYI: here's the solution I ended up using :)