Unity 4.6 UI - How to left-align scroll rect content

I have 2 scroll rects, one has a grid and the other has a text box as content and both are populated at runtime. One is vertical and the other is horizontal but they both have the same issue. When the app starts, the content in both of them is centered instead of starting at the top or left of the content.

For example, one is a horizontal menu that has 5 buttons in it. The scroll rect is smaller than the content (grid of buttons). When the app starts though, it is centered on the middle button, leaving both buttons on either end cut off instead of starting with the first button completely visible. Has anyone else encountered this?

I haven’t tried much to fix it, I don’t really know where to start.

The solution is far easier than you think. As @Nesokas mentioned in a comment you need to alter the pivot on the same object that has your layout component. Changing the pivot to 1 will default everything to the top, 0 will set everything to the bottom.

37070-change-default-position.png

you need to set the anchor on your elements to be where you want the items to start at. you can also set on your content items the order in which you want the items to be populated with the child alignment property, assuming you used a layout group component to lay them out in a grid.

I’m having the same problem. Even when I try to pull the object manually in the editor while running, it doesn’t let me.

I’m using the following code to dynamically populate an object with a vertical layout group:

 RectTransform rooms_avail_rect = rooms_avail.GetComponent<RectTransform>();
 Vector2 new_rooms_avail_size = rooms_avail_rect.sizeDelta; 
 new_rooms_avail_size.y = (index+1)*73; 
 rooms_avail_rect.sizeDelta = new_rooms_avail_size; 
 Vector2 new_rooms_avail_position = new Vector2(0,0);
 rooms_avail_rect.offsetMax = new Vector2(0,0); 
 rooms_avail_rect.offsetMin = new Vector2(new_rooms_avail_size.x, -new_rooms_avail_size.y);

My hierarchy looks as follow:

|
| Rooms (Mask + ScrollRect)
|___| Rooms Available (Vertical Layout Group)
|______| Room1
|______| Room2
|______| ...
|

Edit:
If the objects created exceed the mask height than everything works fine…