The situation is as follows. In Unity3d 5, using embedded UI components, created with scrollRect and scrollBar region with generated content inside.

In the code, I first look at the number of elements that need to be generated-displayed, then increment Rect.size.y on the ElementsCount * индекс высоты одного элемента . ScrollBar automatic, vertical. Dimensions do fine, but constantly when rebuilding the contents of the ScrollBar set in the center of the content, and you need to display on top of the content.

According to the advice in the open spaces - I changed the binding in the UI, but for some reason I did not notice any changes. Perhaps someone has already encountered this problem and will prompt a rough solution. For now, a crutch to write out of thoughts is to calculate the necessary coordinates for the scrollRect itself and move it, but to score on the ScrollBar , but the way out is not the best for me.

Thanks for any help.

  • one
    Attach a picture of what is wrong, but the description is not entirely clear. I understand that you are updating the list of objects and your area puts in the middle of the list. If your scrollBar directly affects the position of the region, and you want after each update of the list of objects in the scrollRect simply reset scrollBar.value to 0. - KingPeas
  • I encountered a similar problem on another resource: answers.unity3d.com/questions/857051 / ... I combined your advice with advice on a resource and it seemed to work. Probably, I will issue in response, what I did in the end. - DarkOwl
  • Set Direction = BottomToTop, and on the advice of the resource I set Pivot = 1. And programmatically set _myScroll.Value = 1 after changing the size of the scrollable field in the script. Before that I tried some options separately and it did not give an effect. And now everything was fine. Thanks for the help. Sometimes not enough. - DarkOwl

1 answer 1

The problem was solved as follows: in the settings, ScrollBar set Direction = BottomToTop , where in the component Pivot was set (Y) to 0.5 - set to 1. In the script, immediately after resizing, scrollRect - set <Мой_скроллбар>.Value = 1;