- Home /
ScrollRect content position is wrong in build
I have a scrollable list of items UI, the items are added from script. It looks good on editor: https://prnt.sc/oim6zn
But offset after i build: https://prnt.sc/oim6iu
I found weird magical way to solve it, by playing the game in unity editor with maximized window, it seems to fix if i build right after the play. However this trick doesn't work anymore when i build the game into APK, the position is wrong on android too.
I have canvas scaler, and all of my other UI elements fit perfectly with different screen sizes. Also the script that adds the items to scrollrect, is modifiying only localposition, so it should be fine from what i know.
I noticed also the content transform value of viewport of scrollrect will sometimes randomly change to random number in editor(not the value of 50% offset, but any other random value).
Basicaly unity ui is very weird ):
Anyone has idea whats going? Thanks
Answer by Mr-Tomato · Jul 26, 2019 at 07:07 PM
Thanks GlassesGuy but the solution was that i needed Vertical Layout Group component. https://docs.unity3d.com/Manual/script-VerticalLayoutGroup.html
It pretty much positions your elements inside content of scrollrect to your wish, instead of doing it from code by changing local position(for some reason it bugged out for me on build).
Answer by GlassesGuy · Jul 25, 2019 at 11:06 PM
Does changing the canvas setting to "constant physical size" not fix it?
Your answer
Follow this Question
Related Questions
Force UIImage to stay on viewport? 0 Answers
Scroll view/rect broken on Android only 0 Answers
Adding a button to the content of the viewport in a scroll view through code? 0 Answers
3ds max viewport canvas 0 Answers
Scroll content disappears after trying to scroll on Android, on different aspect ratio devices. 0 Answers