- Home /
Chat: new messages, bottom of scrollview?
Hello,
I've followed the multiplayer tutorials from GTGD, and I want to change the chat. In some multiplayer games, the new message from other players come under the old messages. But in that tutorial the new messages will come above it (I hope you understand what I mean xD).
Is there mayby an solution so I can calculate the minimum of the scrollPosition, and set the scrollPosition (Y) to that value? I don't know what part of the script you need (it is big..), but a example with the solution is also good.
scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Width(windowWidth - padding), GUILayout.Height(windowHeight - padding - 5));
GUILayout.Label(communication, myStyle);
GUILayout.EndScrollView();
Thanks, Jomaikke
Answer by Coersum · Feb 19, 2014 at 07:39 PM
I know it's an old question but I just went through the GTGD tutorial too and wanted more out of the chat so if anyone else lands here, you will know.
For what you want (newest messages being at the bottom of the chat), in the CommunicationWindow script, you need to change the RPC SendMessageToEveryone from
communication = pName + " : " + message + "\n" + "\n" + communication;
to
communication = communication + pName + " : " + message + "\n";
I removed one "\\n" because there is no need for it and a waste of space imo.
Hmm... I don't have the project anymore, but it seems to be the answer. I didn't know it was so simple xD
Thanks for the reply, I haven't tested this yet, but yes... that does look exactly right lol. All the way down to the double \n's... that was another issue I didn't pick up.
thanks!
You also might want to add the following code in the TellEveryone... RPC functions at the bottom of the script (right under the line I posted in my post above) so that the scrollbar follows the chat.
scrollPosition.y = $$anonymous$$athf.Infinity;
What will happen is when someone types something, the scrollbar will go all the way down to the last message, you can still scroll up in between messages (kind of a fix).
Answer by KuPAfoo · Aug 28, 2013 at 05:00 AM
Are you using photons PUN?
I have the same question xD
tinkering with some things while i wait for a reply
In fact, here's my thread: http://answers.unity3d.com/questions/525380/chat-order.html
Your answer
Follow this Question
Related Questions
Voice chat in browser based unity projects 3 Answers
Multiplayer Voice Chat? 2 Answers
ScrollView performances with huge number of GUIContents. 2 Answers
Unity networking tutorial? 6 Answers
Global Chat between different servers 0 Answers