- Home /
GUILayout.Label - why messages are appearing on each other?
Example: http://piclair.com/n6vb4
Anyway,this happens when i build the game,start the server and join from another pc,and start chatting with each other.The problem is in focus script:
if (Event.current.keyCode == KeyCode.Return) {
GUI.FocusControl ("Message");
}
If i remove that one,and focus textfield with my mouse,it's not happening,they are always appearing normally.
Here's the textfield and submit form:
GUI.SetNextControlName ("Message");
Input.eatKeyPressOnTextFieldFocus = true;
currentMessage = GUI.TextArea (new Rect (0, Screen.height - 20, 175, 20), currentMessage);
GUI.SetNextControlName ("Button");
if (GUI.Button (new Rect (200, Screen.height - 20, 75, 20), "Send")
|| Event.current.keyCode == KeyCode.Return && currentMessage != null) {
SendMessage();
GUI.FocusControl(null);
}
And this is the layout itself:
GUILayout.Space (400);
for (int i = chatHistory.Count - 1; i >= 0; i--) {
GUILayout.Label(chatHistory[i], GUILayout.Width(300));
}
Why is this happening? I found some threads about the same issue,but it was all smth called phontonview,but im not using it. If someone will actually read it,then can you help me to revert the layout,so messages would go from bottom to top,not from top to bottom, so the chat is actually like in all mmorpg's. Thanks alot in advance, i hope someone can help me.
Not an answer, just a tip: Unity 4.6 is released, use the new UI system its awesome! The new GUI system compared to OnGUI is like comparing the size of a grain of sand to the entire universe :)
Your answer
Follow this Question
Related Questions
Lock a textarea/textfield for editing 1 Answer
Unity Scale One Text Field GUI 2 Answers
Multiple Layout Errors with unitys GUI Layout 1 Answer
A node in a childnode? 1 Answer
How do Text Fields work? (Backend) 1 Answer