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

TMP Color Tag for Sprite Asset

Discussion in 'UI Toolkit' started by MousePods, Nov 22, 2021.

  1. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    754
    Hi,

    I was wondering if support for the color tag is coming soon? I am currently having to make a new sprite for every color I need of the same sprite.

    Thanks!
     
  2. mcoted3d

    mcoted3d

    Unity Technologies

    Joined:
    Feb 3, 2016
    Posts:
    970
    Hi,

    If your sprite is assign as a background for a VisualElement, you can use the "-unity-background-image-tint-color" style, like so:
    -unity-background-image-tint-color: rgba(97, 207, 109, 255);


    In C#, that would be:
    Code (CSharp):
    1. visualElement.style.unityBackgroundImageTintColor = Color.green;
    Hope this helps!
     
    MousePods likes this.
  3. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    754
    Last edited: Nov 24, 2021
    mcoted3d and HugoBD-Unity like this.
  4. HugoBD-Unity

    HugoBD-Unity

    Unity Technologies

    Joined:
    May 14, 2018
    Posts:
    440
    Glad you were able to find the issue!

    Yes, you should be able to apply a color to a SpriteAsset like so:
    Code (CSharp):
    1. <sprite index=0 color=#55FF55FF>
     
    MousePods likes this.
  5. WookieWookie

    WookieWookie

    Joined:
    Mar 10, 2014
    Posts:
    34
    Would be best if this was an option on the TextMeshProUGUI component itself.

    Edit: I just found that there IS an option in TMP Settings called Tint All Sprites. I recommend setting this to True and then using color overrides inline, when needed.
     
    Last edited: Jan 11, 2023