Adding Muiltipule GUI.Buttons In an Inventory System Based On Arrays

Is there a way to, from code(JavaScript), to add line of code into my .js file?

I’m working on an inventory system and all my items are identified in an Array, I want to make it so it gets the array length and makes a GUI button for each entry in the array with the corresponding array text for the button text. I also need it so when the button gets clicked it knows what entry in the array needs to be deleted.

I need this answer as soon as possible, I’m trying to finish a system in the next day or two that needs this.

Use a for loop in funtion OnGUI(), you can imagine it would like:

var array : Array[];//your array
function OnGUI()
{
 for(var i:int =0;i<array.Length;i++)
 {
  if(Rect,array_.text)//Rect is the size of the button,array*.text is the text in each element of your array*_

{
array.RemoveAt(i);
}
}
}
It’s just the idea, and you need to write and adjust it all by yourself.