- Home /
Scroll Bar
I have a chat window and i want it to display the last messages from the players at the bottom of the conversation. The problem is that i have managed to do that but window won't go automatically to the bottom of the conversation unless i scroll it there otherwise it remains at the top of the conversation. Does anyone know how I can make it do that automatically?Than you. This is the code that i use for the chat windows
function ChatWindow(id : int)
{
var s : String="";
var ms : message;
GUILayout.BeginVertical();
_chatScrollVector2 = GUILayout.BeginScrollView(_chatScrollVector2, InvisibleStyle, InvisibleStyle);
for(i=0;i<= allText.length-1;i++ )
{
ms = allText[i];
newskin.customStyles[2].normal.textColor = ms.messageColor;
s = ms.getAllText();
var dbgstr : UnityEngine.Color = newskin.customStyles[2].normal.textColor;
GUILayout.Label(""+s, newskin.customStyles[2]);
}
GUILayout.EndScrollView();
GUILayout.EndVertical();
}
Answer by Berenger · Jun 27, 2012 at 03:57 PM
You can set _chatScrollVector2.y to Mathf.Inifity, the Scrollview will clamp it to max.
Note that drawing all the lines of your text with Label is going to be a problem after a undred lines or a thousand, let alone more. Take a look at my question on that subject.
Your answer
Follow this Question
Related Questions
scroll view in iphone 1 Answer
Disabling mouse wheel when user is scrolling ScrollView 3 Answers
Inventory Help. 0 Answers
GUI Label/Text Area Doesn't Show Up Inside Scrollview 1 Answer
The Unity Scrollbar Handle NaN problem 0 Answers