- Home /
GUI Coloring word
How can i change the color of ONE word in GUI.Label?
for example: "(it's white--->) Hi my name is (<--- it's white) (it's yellow --->) Bob (<--- it's yellow)"
               Comment
              
 
               
              If you're using a GUI Text gameObject then you can enable rich text and try using rich text formatting to do what you want. I haven't tried this but it's an idea! Otherwise could you not split them up into separate label's?
Answer by Nicolaj Schweitz · Feb 17, 2014 at 11:38 AM
Try this. I haven't had the chance myself. The answer is based on the docs on GUIStyle.richText and GUI.Label():
 using UnityEngine;
 using System.Collections;
 
 public class Example : MonoBehaviour {
     void OnGUI() {
         Rect rect = new Rect(10, 10, 150, 20);
         String string = " Hi my name is <color="yellow">Bob</color>"
         GUI.Label(rect, string, GUIStyle.richText);
     }
 }
 
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                