Mask Polygon component inside Scroll View

  • updated
  • Answered

Hi. I'm trying to solve a very specific problem and it looks like it should be possible to solve my problem using Stencil buffer, but I can't get it to work.

The idea is that I have a standard "Scroll Rect" unity component and inside the viewport I'm rendering a polyline using the "Polyline" component. The viewport has a "Image" component and a "Mask" component. The "Canvas" is set to world space.

How can I utilize stencil buffers so that the Shapes components don't draw outside the viewport? Attached is a image that illustrates the problem.

Image 595

Reporting a bug? please specify Unity version:
Reporting a bug? please specify Shapes version:
Reporting a bug? please specify Render Pipeline:
Built-in render pipeline
Freya Holmér creator
  • Answered

I forget exactly how, but I believe it's possible to inspect what stencil mask value the scroll rect is using, and then you can read from that very same stencil value using Shapes. The frame debugger should be able to tell you this!