I want to create a stack based fill to mimick a normal chat window.
What GUI contructs do I need to use.
Thanks, stringa
I want to create a stack based fill to mimick a normal chat window.
What GUI contructs do I need to use.
Thanks, stringa
A simple method would be to add the new messages to the end of the current content, then redisplay it in a GUI box (example in C#):
void OnGUI()
{
string chatContent = "This is a chat window
with
multiple
lines";
string newChatContent = "
and
even
more
lines";
if (newChatContent.Length > 0)
chatContent += newChatContent;
GUIStyle style = new GUIStyle();
GUIStyleState styleState = new GUIStyleState();
styleState.textColor = Color.cyan;
style.alignment = TextAnchor.LowerLeft;
style.normal = styleState;
GUI.Box(new Rect(0, 0, 400, 200), chatContent, style);
}
Instead of a string for the content you could use a List of strings, which would provide easy addition and removal of lines.
As for a way to enter messages, look into GUI.TextField. See also the GUI Scripting Guide:
http://unity3d.com/support/documentation/Components/GUI%20Scripting%20Guide.html
This is an interesting post about how to make a chat system:
http://forum.unity3d.com/threads/50369-Hep!-Display-what-you-have-entered-in-chat-window