Spawning an OnGUI Button

I’m working in Javascript, and right now I’m trying to figure out if there is any good way to spawn a GUI.Button during game play.

What I’m hoping to do is spawn a series of buttons on one side of the screen that will travel to the other side of the screen and disappear when clicked. I know how to handle the movement half of this behavior, its the generating and destroying new GUI buttons during run time.

Let me know if you have any ideas on how to approach this, psuedocode would be fantastic, even pointing me in the right direction would be great.

In the meantime I’ll let you all know if I figure anything out on this

You just use booleans to decide if a certain GUI element, like a button, should be drawn or not.

var drawButton1;

function OnGUI() {
     if(drawButton1 == true) {
          //GUI.Button code
     }
}