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

Question Is it possible to fade an element to full transparency?

Discussion in 'UI Toolkit' started by ontrigger, Nov 28, 2022.

  1. ontrigger

    ontrigger

    Joined:
    Oct 31, 2016
    Posts:
    24
    I'd like to fade the bottom part of an element to full transparency like this:
    upload_2022-11-28_21-40-23.png
    I used mask-image with linear-gradient to achieve this effect in browser, but mask-image is not currently implemented. Is there any workaround for this?

    I tried manually setting the vertex tint, but it only affected the background rather than the content itself. It was basically the same as setting background-color: rgba(255, 255, 255, 0.5) which is not what I want.

    Any solution to this?
     
  2. Neutron

    Neutron

    Joined:
    Apr 25, 2011
    Posts:
    45
    There's an opacity property in the display group. Use that.
     
  3. ontrigger

    ontrigger

    Joined:
    Oct 31, 2016
    Posts:
    24
    In case you didn't read the first paragraph let me repeat: I would like to fade a specific part of the element, not the element itself.
    AFAIK there is no way of doing that either per vertex or by using a mask.
     
  4. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    4,404
    Maybe a custom shader with a mask texture to know where to fade?
     
  5. ontrigger

    ontrigger

    Joined:
    Oct 31, 2016
    Posts:
    24
    It is a possibility, but would be difficult to implement. I'd have to render both the background and the element I'd like to fade to a texture. Unfortunately, there is no way to inject commands during the uitk rendering process, meaning I'd have to separate the bg and the element to separate panelsettings. Very clunky solution.