Hi!
I’m adding text items to a scroll rect (through code) and the items are at the right spot but the last ones are outside the area. As you can see level_14 is half outside and level_15 is completely invisible when the vertical bar is at the bottom (dragging with the mouse conforms that it’s there but when i release the mouse it goes back down). All items are children of “content”. Changing the scroll bar size at runtime in the inspector doesn’t work as unity scales it back immediately. Any ideas?
Ok i figured it out, I’ll post the answer in case anyone else needs it. So it seems the content does not scale itself, you need to manually calculate it’s size.
I added this to my code and now it works:
RectTransform rt = content.GetComponent<RectTransform>();
rt.sizeDelta = new Vector2(rt.sizeDelta.x, 20 * rt.childCount); //20 is the height of the item