How do you make a gui button appear under the one above it, automatically?

[18118-screenshot+(386).png*_|18118]Hey again :slight_smile:

I have one more problem :\

I have a screen displaying the amount of servers available, if there is more than one, they will overlap with each other.

I was wondering how I would make it automatically place the next gui button under the one above it?

if there is 5 servers, there should be 5 buttons, one under the other.

I attached a screenshot to show what its doing, there are 2 servers available that are overlapping.

I don’t have much experience with this part. Cheers, Tim.

Here’s the part where it loads the buttons if it helps.

function OnGUI (){

    for (var i:int = 0; i<hostData.length; i++){
    
      
    if( GUI.Button(Rect(110, 155, 300, 100),hostData *.gameName)){* 

if (!Network.isServer && !Network.isClient){
Network.Connect(hostData*);*
}
}
}
_*

2 Answers

2

To the y position of the button add an y offset value based on the server’s index number.

So the first server (index 0) would be y + 0 * button height, the second (index 1) would be < + 1 * button height, and so on.

cheers I will give it ago

–

You need to work with the Rect, basically what you need is Rect(110,155+i*100,300,100) But be aware that if there will be more then your screen can accommodate it will just flow down. For that you need to place it in a scrollview i believe.
You can read about the scrollview here:

cheers I will give it ago

–