Search code examples
unity-game-engineunity-ui

Unity Rect Mask 2d overflow


image here

I am using a Rect Mask 2d on a scroll bar area to hide elements outside the viewport of the scroll.

And to an extent, this works. the UI element shown in red will not appear until the user scrolls down to it.

However when a UI element is partially within the viewport. The entire element is rendered. This is not what I want.

If a UI element cannot be shown entirely in the viewport. id like for the element to either disappear completely or preferably, I would like it so that the portion of the UI element within the viewport is rendered, while the portion outside the viewport isn't.

I have already experimented with a Mask (not Rect Mask 2d) but it seems that they don't like to work with UI elements.

If anyone has any tips or ideas as to how I can solve this. I'd be happy to hear you out.

Thanks in advance


Solution

  • It turns out that setting the Material of the text was forcing the entire thing to be rendered.

    if I just use the default material, it will not overflow.