- Home /
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 += "\n> "+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:\n\n WASD: Move \n Mouse: Look \n ESC: Menu \n P: Hide/Show Dev text \n\n Other: \n\n If you get stuck press <>"); GUILayout.EndArea(); GUILayout.EndArea(); }
Thanks.
Answer by CgShady · Mar 14, 2013 at 10:31 AM
If I'm not mistaken, GUI.contentColor is only available within OnGUI () {}
Try void OnGUI () { if (type == LogType.Warning) { GUI.contentColor = Color.yellow; } }
No, that still doesnt appear to have worked (And i did put the type into a logtype veriable). http://i.imgur.com/OzS5b4o.jpg
Ah nvm, just realized that it will change every script with GUI to red (type = logtype.error worked but the rest didnt)
Your answer
Follow this Question
Related Questions
Drawing 4 GUIButton's with a forloop. Need help changing color? 1 Answer
Gui list and color 0 Answers
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer
How to change a buttons color? 2 Answers