- Home /
C# How to Make Stack of Buttons and Labels not Even
Hi everyone, I have noticed in my script that the stack of buttons and labels are even. Since I have it divided by 3 it will have 2 buttons and 1 label. Is there a way to have it not be even and have it be different in certain areas?
using UnityEngine;
using System.Collections;
public class SomeGUI : MonoBehaviour {
public string[] someText;
void OnGUI () {
someText= new string[] {"Text1","Text2","Text3","Text4","Text5","Text6"};
for(int i = 0; i < someText.Length; i++){
if (i % 3 == 0){
GUILayout.Button(someText[i], GUILayout.Width(142), GUILayout.Height(25));
}
else{
GUILayout.Label(someText[i]);
}
}
}
}
Comment
Answer by SubatomicHero · May 22, 2013 at 07:00 AM
Read up on the GUI begin horizontal, vertical, area scriptung reference. It will help alot with your positioning needs.
Your answer
