i have a problem with printing GUI elements in for loop pf OnGUI() method. In code listed below i create GUI.Label of user clicked on GUI.Box:
public List<string> messages = new List<string>();
int dialogueMsg = 0;
void OnGUI()
{
Event currentEvent = Event.current;
if (enabled)
{
GUI.BeginGroup(new Rect(Screen.width / 8, Screen.height / 4 + Screen.height / 2, Screen.width - Screen.width / 4, Screen.height / 4));
GUI.Box(new Rect(0, 0, Screen.width - Screen.width / 4, Screen.height / 4), "");
if (currentEvent.button == 0 && currentEvent.type == EventType.mouseDown)
{
for (int i = 0; i < messages.Count; i ++)
{
if (dialogueMsg < messages.Count)
{
print(dialogueMsg);
print(messages[dialogueMsg]);
GUI.Label(new Rect(25, 25, Screen.width - Screen.width / 4, Screen.height / 4), messages[dialogueMsg]);
++dialogueMsg;
break;
}
else
{
enabled = !enabled;
break;
}
}
}
GUI.EndGroup();
}
}
And when user clicked - nothing happend, except printing correct values dialogueMsg and messages[dialogueMsg]. What am i doing wrong? Did anybody is familiar with this problem?