I have a ScrollRect with a viewport that contains a RectMask2D.
The content of the ScrollRect has a list of children, expanding beyond the viewport (so they get culled by the RectMask2D).
I remove the top most child and move to the top of the list.
I do so by first setting the childs parent to null and then destroying it, then I set the ScrollRect’s verticalNormalizedPosition to 1. This works fine.
But any element (or subelement) not visible, when doing the verticalNormalizedPosition = 1, will not be shown until after manual scrolling happens.
Am I missing any layout or mask calls to get it to update?
I tried a bunch of things to get it to do what I wanted. I read someone else yesterday suggesting doing a LayoutRebuilder.ForceRebuildLayoutImmediate to force an update that same frame. Maybe that actually works better, instead of having everything update.
But mine worked… if LayoutRebuilder doesnt work, try waiting a frame or a second and see if it then triggers the update (whether you do a LayoutRebuilder or a Canvas update)
(I was/am using 5.2.1p3 btw, but probably gonna make the switch to 5.3 now, because of all the ui updates)
You’re using a ScrollRect and RectMask2D… successfully I gather. How did you set it up? I posted a separate thread, but no replies. It must work in some fashion.
I create ScrollRect, remove RectMask and replace it with RectMask2D in same location. Maybe it’s the version I’m on? 5.2.2p4.
Sry for the late response, Yukichu. I had a release and then holidays, so I forgot to check your question.
I thought I was using RectMask2D, but I am using a RectMask and not the 2D version, as I had problems with getting the 2D version to work correctly as well. I cant remember what the specific problem was, though, I believe it was a culling problem. Using the RectMask I have not noticed anything problematic in my case.
I just tried to add a RectMask2D in 5.3.1p1 and it “seems” to work fine, but I have not tested it throughout my application, since the RectMask is doing the job just fine atm.