Search Unity

Unity UI Text not changing color

Discussion in 'Editor & General Support' started by BlakeGillman, Jul 18, 2018.

  1. BlakeGillman

    BlakeGillman

    Joined:
    Dec 7, 2013
    Posts:
    412
    I don't know if using <color=> is deprecated or something since in previous projects this has worked but it simply isn't working with my UI text

    Code (CSharp):
    1. Text RoomNameText;
    2. public void SetRoomNameText (string name, string map, int players, int maxPlayers)
    3.     {
    4.         RoomNameText.text = "Transmission: <color=yellow>" + RoomName + "</color>, received from: <color=yellow>" + map + "</color>, units responding: <color=yellow>" + players + "</color>/<color=yellow>" + maxPlayers + "</color";
    5.     }
    which returns that string exactly with no formatting whatsoever.


    EDIT:
    I tried setting the text to just be "<color=yellow>" + map + "</color>" which still didn't work
     
    Last edited: Jul 18, 2018
  2. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    Use TextMesh Pro instead. It's much better and already integrated into Unity.
    If you're on 2017+ use Package Manager, otherwise you can find it on the Asset Store page.

    Also, for the default text component - make sure that Rich Text is enabled on it.
     
  3. BlakeGillman

    BlakeGillman

    Joined:
    Dec 7, 2013
    Posts:
    412
    Thanks, I finally know what "Rich Text" does lol
     
    karl_jones likes this.