- Home /
Change the color of the string
Hey all, i have a "combat window" in my game, and i want to change the "destroyedName" color to red, and the "attackerName" to blue, but i cant figure out how to do this...
Here is my code:
//unity code
public string attackerName;
public string destroyedName;
private string combatLog;
public GUIStyle myStyle = new GUIStyle();
void Start () {
 myStyle.fontStyle = FontStyle.Bold;
     
 myStyle.fontSize = 11;
 myStyle.normal.textColor = Color.red;
}
void CombatWindowFunction (int windowID) {
 GUILayout.Label(combatLog);
}
void OnGUI () {
 if (attackerName !="")
 {
 combatLog = attackerName + " killed " + destroyedName + "\n" + combatLog;
 }
}
}
Answer by legion_44 · May 31, 2013 at 03:36 PM
Try this one:
 GUI.Label(new Rect(0, 0, 0, 0), combatLog, myStyle);
Answer by Dank_Mushies · Apr 23, 2016 at 10:46 AM
hey i'm not sure if you still need help but try this:
      combatLog = "<color=#ff0000>"+attackerName +"</color>" +" killed " + "<color=#0000ff>"+destroyedName + "</color>"+"\n" + combatLog;
     
 
Your answer
 
 
             Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Gui list and color 0 Answers
Changing color of select section of text 0 Answers
Multiple Cars not working 1 Answer
Generate Json from Class Type List 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                