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
0
Question by Alduno · Apr 13, 2018 at 02:29 PM · uiscrollviewviewportscroll view

Make Scroll View size fitting to children size in one dimension

This is a part of my current hierarchy:

 Scroll View
   Viewport
     Content
       Button_1
       Button_2
       Button_3
   Scrollbar Vertical


Content has a Vertical Layout Group and a Content Size Fitter, so all buttons are below each other and their size also defines the size of Content. Now I want the Viewport and Scroll View width to also be fitting to the Content but the height of course not, so that the buttons are scrollable in the top-bottom direction and perfectly fitting in the left-right direction.

I already tried adding a Content Size Fitter to Scroll View and Viewport but as soon as I set the Horizontal Fit to Preferred Size the width very small.

What is the correct way to do this? Thanks in advance!

Comment
Add comment · Show 2
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 JChilton · Apr 13, 2018 at 04:26 PM 0
Share

The issue with adding a size fitter to scrollview and viewport is that this is not how it's supposed to be set up. Scroll View can be any size, Viewport is the "window" you want your scrollables to live and be constrained to, and Content is the block that gets moved around.

If you have your viewport the same size as your content window, then there is no scrolling, as all items are already displayed.

If you want them to fit horizontally, it's best to just set the width of view port manually, since there are often funky results when parenting multiple content fits on top of one another.

avatar image Alduno JChilton · Apr 13, 2018 at 06:39 PM 0
Share

If you have your viewport the same size as your content window, then there is no scrolling, as all items are already displayed.

The horizontal dimension should be the same and only in the vertical scrolling should be possible. So there is no contradiction.

If you want them to fit horizontally, it's best to just set the width of view port manually, since there are often funky results when parenting multiple content fits on top of one another.

Possible, but then I have to update this manually every time I change something in one of the lower layers, for example increasing the size of a Button to fit an image.

0 Replies

· Add your reply
  • Sort: 

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

132 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 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 to check if child item is visible in ScrollView? 1 Answer

Scroll view/rect broken on Android only 0 Answers

Focus on Selected Item in Vertical Scrollview 0 Answers

Scroll rect snaps everytime with drag 0 Answers

Camera Viewport detecting objects behind 0 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