c# - Change GUIlayout.lable colour based on logtype?

hi,

Im trying to make a console and i have the debug log otputting, Just wondering how i would change a GUIlayout lable colour based on type, GUI.contentcolor does not work.

– Log to text

	void HandleLog ( string logString, string stackTrace, LogType type){
		if(type == LogType.Warning)
		{
			GUI.contentColor = Color.yellow;
		}
		outPut = logString;
		stack = stackTrace;
		myLog += "

"+outPut;
}

– GUI

		if(console)
		{
			GUILayout.BeginArea(new Rect(0,0, (Screen.width), 300),"Console","Box");
			GUILayout.BeginArea(new Rect(0,40, (Screen.width / 2), 260), "Debug Outut", "Box");
			GUILayout.Label(myLog);
			GUILayout.EndArea();
			GUILayout.BeginArea(new Rect((Screen.width / 2),40,(Screen.width / 2), 260), "help", "box");
			GUILayout.Label("Controls:

WASD: Move
Mouse: Look
ESC: Menu
P: Hide/Show Dev text

Other:

If you get stuck press <>");
GUILayout.EndArea();
GUILayout.EndArea();
}

Thanks.

If I’m not mistaken, GUI.contentColor is only available within OnGUI () {}

Try
void OnGUI ()
{
if (type == LogType.Warning)
{
GUI.contentColor = Color.yellow;
}
}