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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Rich Text for variables

Discussion in 'Immediate Mode GUI (IMGUI)' started by jessee03, Nov 6, 2013.

  1. jessee03

    jessee03

    Joined:
    Apr 27, 2011
    Posts:
    729
    I know Rich Text can be applied to Strings but is it possible to apply Rich Text to variables that are added to GuiText? Such as ( "<b>Text1</b> " + myIntVar). My question is if it's possibly to apply bold to the myIntVar as well?
     
  2. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    1,882
    Have you tried?

    It's just strings. If you add a string and a number, it concatenates the string with a string representation of the number. You can add more string bits after that.

    Code (csharp):
    1.  
    2.     ("<b>myIntVar is currently " + myIntVar + "</b>")
    3.  
     
    esitoinatteso likes this.
  3. jessee03

    jessee03

    Joined:
    Apr 27, 2011
    Posts:
    729
    Oh wasn't aware that you could transfer over the rich text between Strings like that. I guess in the end it all gets combined. I'll go try it out.

    Edit: Works perfectly! Thank you. Guess I was derping to not think of that.
     
    Last edited: Nov 6, 2013
  4. esitoinatteso

    esitoinatteso

    Joined:
    Sep 23, 2013
    Posts:
    26
    Hey there! I know it's necroposting, but thanks!