Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by falantar14 · Oct 22, 2014 at 03:51 PM · uiguiunity 4.6scrollview

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.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Kiwasi · Nov 25, 2014 at 05:57 PM 0
Share

Something is weird here. A quick test on my machine has the content starting where ever I put it in the editor.

3 Replies

· Add your reply
  • Sort: 
avatar image
12

Answer by Ash-Blue · Dec 15, 2014 at 04:15 PM

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.

Edit this field


change-default-position.png (12.5 kB)
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by delta sniper · Oct 24, 2014 at 01:10 AM

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.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image falantar14 · Oct 27, 2014 at 01:45 PM 1
Share

I've already done all of that. It hasn't worked.

avatar image delta sniper · Oct 28, 2014 at 02:31 AM 0
Share

show me some screen shots of your editor window maybe you have over looked something.

avatar image
0

Answer by Nesokas · Nov 29, 2014 at 12:43 AM

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...

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Nesokas · Nov 29, 2014 at 01:10 AM 4
Share

Ok I think I solved it. Just change the pivot of the content, in my case was "Rooms Available" ($$anonymous$$e was in the center) and it should work fine.

avatar image wangunity Nesokas · Mar 15, 2016 at 01:57 PM 0
Share

solve my problem too

avatar image Jix · Jan 28, 2015 at 08:57 AM 0
Share

@Nesokas Thanks a lot, this solved my problem

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

unity scrollview doesnt bounce 0 Answers

What's the most practical way to show particles on a "Screen Space - Overlay" Canvas with the new GUI (uGUI, Unity 4.6+)? 0 Answers

UI is not visible on Android lollipop after upgrading from 4.6 to 5. 0 Answers

Why is my vertical layout group not spaced correctly? 1 Answer

ScrollRect (Elastic) wait to scroll back to Start 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges