Search Unity

Question Disable original VisualElement mesh when using generateVisualContent

Discussion in 'UI Toolkit' started by danm36, Jun 24, 2020.

  1. danm36

    danm36

    Joined:
    May 18, 2016
    Posts:
    10
    Pretty much as the title says. I'm currently using the VisualElement's generateVisualContent delegate to generate a custom mesh, but I want to co-opt a number of the existing style settings for this new mesh (Background colour, border settings, background image and so on). Unfortunately, when I set those style elements, the original element renders underneath my custom mesh. Is there any way to suppress the generation of the original element?

    I am using this for runtime with version 0.0.4-preview just in case this was a known issue - I haven't tried generateVisualContent with editor elements.
     
    floriankorsakissok likes this.
  2. mcoted3d

    mcoted3d

    Unity Technologies

    Joined:
    Feb 3, 2016
    Posts:
    1,003
    The generated mesh will always be combined with the other styles of the element. It will be drawn after the background and borders.

    At this time, the only way to prevent that would be to remove extraneous styles from your element.
     
  3. danm36

    danm36

    Joined:
    May 18, 2016
    Posts:
    10
    I suspected as much. As an alternative question then, is there currently a built in way to use an alpha mask on elements? If not, that's fine, I'll use my custom element and stick the relevant style settings on my UxmlTraits class instead.
     
  4. mcoted3d

    mcoted3d

    Unity Technologies

    Joined:
    Feb 3, 2016
    Posts:
    1,003
    Not at this time, although this is a feature that's planned in the future.
     
    dsfgddsfgdsgd and danm36 like this.