Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

TextMesh Pro Apply colour to inline sprites

Discussion in 'UGUI & TextMesh Pro' started by torngamesltd, Mar 9, 2023.

  1. torngamesltd

    torngamesltd

    Joined:
    Nov 13, 2020
    Posts:
    2
    Hi,

    We have been using TMP for a while now but haven't found anything on this topic and wondered if it was possible. We use inline sprites for things like currency throughout our game and it works great, but we've recently been looking to add in a bit of onboarding support and run into a bit of a problem.

    Basically, we go through all the items on the screen to darken them down, which for images and text works great (and we can fade it down as well using tweens), but the colour change doesn't seem to apply to a sprite.

    The code we're using is super simple for text:

    Code (csharp):
    1.  
    2. public void SetBrightness(float brightness)
    3. {
    4.     _text.color = _color * new Color(brightness,brightness,brightness,1);
    5. }
    6.  
    but, as I say, this doesn't apply to the sprite
    upload_2023-3-9_0-49-24.png

    The only thing I've found is applying hex colour to the actual text, which isn't ideal really as all the text boxes would need parsing to see where <sprite=?> appears and add to it.

    Is there some other way we can do this?

    Thanks