Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
2
Question by saldavonschwartz · Jun 08, 2016 at 09:42 PM · unity 5uiscrollview

Can't use horizontal layout with ScrollRect scrollview in Unity 5.3.3f1

I read the docs, watched a couple videos and still cannot get this to work. I'm not sure if I am doing things wrong or if Unity broke it. Hopefully it is just me, but since they already broke UI rendering to texture in 5.4.x and I had to revert to 5.3 and in 5.3 I see UI elements not updating in the editor at times, I wouldn't be surprised if this is broken too.

Basically, I'm trying to create a horizontal scrollview with a bunch of elements inside, each taking up the whole 'viewport' dimensions and have the 'content' of the scrollview both resize dynamically depending on the number of elements and also apply horizontal layout to the items.

Essentially this:

alt text

I'm including a sample project and even a video of it (inside the zip attached).

The gist of what I tried is:

  1. Create scrollview from UI menu (notice now there is a new 'scrollview' as opposed to 'bare' ScrollRect -- but I also tried with the ScrollRect).

  2. The default scrollview object from the menu assumes as vertical layout, so I changed the content's transform to flexible height and absolute width.

  3. Added a bunch of images to the scrollview's content, with layout element components with a min width equal to the scrollview's width.

  4. Tried adding horizontal layout group and / or content size fitter to scrollview's content.

The problem is that the content does not resize, staying always at exactly the size of the viewport. Tried the content fitter too... same thing.

Any help would be gladly appreciated. Thanks!

screen-shot-2016-06-08-at-22812-pm.png (155.7 kB)
Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by Brijs · Jun 10, 2016 at 12:04 PM

Here you can use Grid Layout group instead Horizontal Layout Group with Content Size Fitter as follows

Go to Hierarchy-->Canvas-->ScrollView-->ViewPort-->Content Attach GridLayoutGroup and ContentSizeFitter component to Content object and set parameters as shown below

alt text

Here cell size is the size of ScrollView.

Now you can add elements dynamically to Content gameobject and content will resize automatically allowing added elements to be fixed sized(Cell size of GridLayoutGroup).

You can refer attached package

Dynamic Scroll View.unitypackage


content-sizefitter.png (15.3 kB)
dynamic-scroll-view.zip (9.2 kB)
Comment
Add comment · Show 1 · 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 saldavonschwartz · Jul 29, 2016 at 05:25 AM 0
Share

Thanks for putting in the effort in even making a package.

I'm accepting your answer because it works. But I think of it as a workaround, and I am still wondering why would the horizontal layout not just work.

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

90 People are following this question.

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

Related Questions

How do I dynamically update a rect scroll from a List? 0 Answers

Unity 5 UI Scroll Rect Problem 0 Answers

Scroll Rect with Grid Layout not working properly. 2 Answers

Performance issue with ScrollRect.LateUpdate() 1 Answer

Make an snapped ScrollView 2 Answers


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