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

Change button color

Discussion in 'UI Toolkit' started by angel1st, Jan 15, 2020.

  1. angel1st

    angel1st

    Joined:
    Nov 16, 2019
    Posts:
    35
    Hi there,
    I have a weird behavior when attempting to change button color.
    I have a button created. Then I simply add a source image. Then I want to change its color. For two of my sprites, this simple action does not change image color. For others - it works.
    Here are two sprites, which when used as source image does not allow to change button color:

    sprite_png.png
    sprite_svg.png

    and the next one is one, where the color can be changed:

    sprite_white_png.png

    I would really appreciate your help guys, thanks!
     
  2. BinaryCats

    BinaryCats

    Joined:
    Feb 8, 2016
    Posts:
    317
    The color (tint) is multiplied by each pixel of the image. So black multiplied by any color would be black e.g. a black pixel from the source image multiplied by red (0,0,0)*(1,0,0)=(0,0,0) - black

    Where as white pixel from the source image multiplied by red (1,1,1)*(1,0,0) = (1,0,0) - red

    Hope this helps
     
    angel1st likes this.
  3. angel1st

    angel1st

    Joined:
    Nov 16, 2019
    Posts:
    35
    Thanks, man, it makes things completely clear!