- Home /
how can i create a second label? ----- Help me
Hi all,
in my code i wrote one code like this
foreach(string s in Pendulum2.threevalues) {
GUI.Label(new Rect(0,hieght,400,40), s ,fontstyle);
hieght = hieght+50;
print (hieght);
}
But my purpose is i want to display first data and second data and third data so on.. but i think my above code is first displayed after then hieght increased after then before value removed or moved and came in to second place.
my window is like
but i want
How will i design a structure. for my code. please give a suggestion.
Thanks in advance
shankar
To show more than one you would have:
GUI.Label(new Rect(0,hieght,400,40), <refrence1> ,fontstyle);
hieght = hieght+50;
GUI.Label(new Rect(0,hieght,400,40), <refrence2> ,fontstyle);
hieght = hieght+50;
GUI.Label(new Rect(0,hieght,400,40), <refrence3> ,fontstyle);
hieght = hieght+50;
You will need to replace refrence1..refrence2 and refrence3 with an actual refrence to where your string values are stored.
Assu$$anonymous$$g Pendulum2.threevalues is an array you would use:
var i = 0;
GUI.Label(new Rect(0,hieght,400,40), Pendulum2.threevalues[i] ,fontstyle);
i = i + 1
hieght = hieght+50;
GUI.Label(new Rect(0,hieght,400,40), Pendulum2.threevalues[i] ,fontstyle);
i = i + 1
hieght = hieght+50;
GUI.Label(new Rect(0,hieght,400,40), Pendulum2.threevalues[i] ,fontstyle);
hieght = hieght+50;
Your answer
![](https://koobas.hobune.stream/wayback/20220613100426im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Something is missing in my code can any body help me? 0 Answers
Problem Displaying Score on GUI text 0 Answers
Display problem with OnGUI 3 Answers
Display a objects property. 1 Answer