I am just going to give this a shot as I do not fully understand your explanation.
From your code fragment, you are just outputting the 3 sets of communication separately. From what I can see, I think that in your current script, you just append the latest message to a string variable or gui content ( communicationWhisper, communicationTeam, communication ). By doing so, you can only sort them by separately, not as a whole chat.
What you need to do is to create a new class to store the message.
public enum CommType{ NORMAL, WHISPER, TEAM };
public class Message {
public string content;
public CommType commType;
public Message( string cont, CommType ct ) {
//Standard constructor
}
}
Then, in your chat script
List <Message> chat = new List<Message>();
All message will go to this chat variable. Whenever there is a new piece coming in:
chat.Add( new Message("My Message", CommType.WHISPER ) );
On output, do this:
//We are iterating the list in reverse order, as the newest message starts from the back
for(int i = chat.Count - 1; i >= 0; --i ) {
//Use either a function or a if-else structure to determine the textColor,
//I am using a function in this example
myStyle.normal.textColor = CommColor( chat*.commType );*
GUILayout.Label( chat*.content, myStyle );*
}
Hope that this is what you are looking for.
----------
## Code Test ##
This is what I got after implementing the codes. By the way, I wrote a test class that send messages to the chatControl
object by detecting different Input.GetKeyDown(KeyCode.??)
I hope that this code is what you are looking for.
[8462-screenshot.2.png|8462]_
_[8463-screenshot.4.png*|8463]*
_*
_*