That’s what I’m doing right now, but things a bit more complex than that man:
int lines = 0;
x = 5;
using (List<GameObject>.Enumerator enumerator = new List<GameObject>(this.myDict.Keys).GetEnumerator())
{
while (enumerator.MoveNext())
{
GameObject gameObject = enumerator.Current;
if (condition_here)
{
//doing stuff
var displayValue = somevalue;
if (condition_here && displayValue > x)
{
GUI.Label(new Rect(1560f, 180f + (float)(lines * 30), 340f, 30f), stuff);
}
else if (condition_here && GUI.Button(new Rect(1560f, 180f + (float)(lines * 30), 340f, 30f), stuff)
{
//doing stuff on button press can't increment lines++ here
}
lines++;
}
else
{
//doing stuff
}
}
//doing stuff
}
}
As you can see depending on some condition I either want to display stuff as simple label OR as clickable buttons and for each case I need to keep track of position.
For now, because my GUI elements tired to dictionary state I used workaround to get total lines I will display and draw them from highest to lowest. Still, a clean, universal solution would be nice
I can’t nest that one, both IFs check specific states and there are dozens of other states therefore the rest will match with “else”, already been there.
Plus, your example does not make a difference because lines++ still incrementing and it just wont display one of the label but because I use “lines” to increment offset for Rect height value it will be displaced again, i.e. label 1 matches and drawn, label 2 does not match and skipped, label 3 matches and drawn but not below label 1 because we’ve only skipped label 2 being drawn but “lines” were incremented.
And then there is second case when button condition has to display ALL buttons according to “lines” so “lines” cannot be messed with in general
So… you need to draw a picture so I can understand what you need, and post the actual code thats giving you problems.
I’ve given you a solution to the code snippets you posted both times, but aparently thats not the actual code you are using…