- Home /
[Solved] need help regarding autolayout in scrollrect
Hi All,
I want to implement the scrollrect which will have 3 different height section. (please refer the attached image).
For ex. Section 1, height = 80pixel Section 2, height = dynamic (as per content) section 3, height = dynamic
all section's width should be equal to parent's panel width Also sections need to be align vertically
I have tried using content size filter, aspect ratio filter, vertical layout group, grid layout group But unable to get the correct result.
Can someone pls suggest me the correct way to achieve this?
Thanks in advanced Chetan
Answer by GlatiatorRX · Oct 06, 2015 at 04:44 PM
The new UI is very picky, haha. And you can do things in a million different ways. What I would suggest, is have a hierarchy like this.
ScrollRect (Technically the main panel)
HolderPanel (This will have your content size fitter & a vertical layout group)
TitleText (Both the text component and a Layout Element component)
SectionTwoGrid (Content Size fitter & Grid Layout group)
GridElement (Layout Element component)
SectionThreeVertical (Content Size fitter & Vertical Layout group)
VerticalElement (Layout Element component)
This should give you a generic layout that you can work off of, but anchors, positioning, and scaling is all up to you my friend. Whatever looks good. A word of advice, for your layout group elements, if something does not seem to center correctly, try editing the pivot vectors in the inspector (rect transform).
Any other questions or if this does not work, I will be around to refine this answer for you.
~ Matt
Your layout elements will give you your specified widths and heights by the way. So if you want your title to be 80 high, set it your content size fitters to your $$anonymous$$ constraints and make sure the layout elements are all defined as such.
Hi $$anonymous$$att
thanks for your quick help i am hunting for the solution almost a week now and what i got so far is only frustration very very poor documentation unity provided regarding content size, aspect ration filter and layout groups (as per my knowledge - most of developer need to use these, especially when you have targeted Universal build)
anyway let me try as per your suggestion
if you can help me to setup children of full width (anchor with full width) when parent has vertical component and content size filter. I stuck specifically at this point
thanks a lot friend again for your quick suggestion
I made a little test scene for you. I hope this works. It has all the elements you wanted, and the width does rescale. But the grid is tricky. You may need to add some other parameters to rescale those, or add a script to do it on the fly. But as of right now, this may help.
Thanks a lot GlatiatorRX for your source code this is what i am looking for perfect example, this will fulfil all my requirement let me understand it thoroughly
you save my life man
Edit how do i convert this comment as accepted ans
Your answer
Follow this Question
Related Questions
Scrollable zooming list 0 Answers
How can I programmatically tween a Scroll View to a desired position? 0 Answers
Scroll A Text Once It Reaches The End Of The Viewport 0 Answers
Scroll View: Is there a way to discriminate and accept only certain PointerEvents? 0 Answers
Scroll Rect Min/Max Size 0 Answers