0

Lets say i have a canvas with a panel containing a plain white image. Hidden by mentioned panel, there is a panel with a coloured image on it. Now lets take a scrollrect, fill it with some smaller panels as content, add a mask to each of those, and put the scrollrect in a panel on top of the plain white panel.

How could i make these scrollable small panels mask out the white panel and show the coloured panel below while the white panel and coloured panel are static and don't move?

I am well aware of the fact, that the white panel and coloured panel would have to be children of the mask component, and that's the problem, because then they would scroll along.

I searched the web a bit, but could only find stuff related to scrollrect viewport masking but not putting masks in a scrollrect.

EDIT: One way would be to directly mask the coloured panel by using each of the small panels as masks and make the coloured panel scroll inside each small panel by *-1 to counter the parent scroll, but that seems like a bad solution

Thanks for any kind of advice <.<

2
  • Could you also include code of what you tried? Commented May 17, 2020 at 19:02
  • I didn't try anything yet because i don't understand the basic concept of how to make the coloured panel static if it has to be child of the scrollable mask component. Commented May 17, 2020 at 20:00

1 Answer 1

1

Use a mask or better yet a rect mask 2d. You add this component to a parent, and all of the children get masked based on its ‘rect transform’ which will show up in the top right of the editor on applicable UI elements. Also you can toggle the gizmo on and off to view a green outline.

https://docs.unity3d.com/Packages/[email protected]/manual/script-RectMask2D.html

Combing rect mask 2d with scroll rect can give you some powerful results and definitely accomplish what you need.

https://docs.unity3d.com/Packages/[email protected]/manual/script-ScrollRect.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.