Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Is it possible to have more than one color within a Label text string? (Editor code)

Discussion in 'UI Toolkit' started by MostHated, Nov 1, 2020.

  1. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    1,218
    Hello,
    I want to say prior to UI Toolkit, it was possible to have a string of text and change it's color midway through the text by doing something along the lines of "<color=WhateverColor> This is </color> a text string". Is there a way to accomplish something like this with a UIElement Label in editor code without having to just have several separate labels lined up in a row, or is that the only option?

    Thanks,
    -MH
     
  2. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,203
    This will come in 2021.1. It's already functional. We're just polishing and getting it out the door.
     
    MostHated, Ghat-Smith and Kirsche like this.
  3. karmatha

    karmatha

    Joined:
    Aug 25, 2012
    Posts:
    50
    It's working for me (Unity 2021.1.23)

    Code (CSharp):
    1. Don’t have an account? <color=#FA917D>Sign Up</color>
    it feels a bit backward though. It would be much more consistent and powerful to be able to add inline level elements just like in HTML.
     
  4. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    1,218
    Great to see that it is in now, but, unfortunately, DOTS is not supported in 2021.x. I am stuck on 2020.x until, well, whenever, I guess.