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 DMCH · Feb 17, 2015 at 01:57 PM · uisizegridlayoutpanel

Increase height of panel w/ gridlayout when new objects added

Hi,

Have recently started using the new gui system, but have become a stuck with increasing the vertical size of a panel with a gridlayout, as new objects are added to it. This is for an inventory system. Objects already in the current inventory are added to the panel with code & prefabs, and objects from other inventories can be dragged and dropped.

alt text

The prefabs are set to 250 x 125, and the grid to the same. I've include a scene and game screen grab. If anyone can give me a nudge in the right direction, I'd be very grateful.

alt text

inventorygame.png (36.0 kB)
inventory-scene.png (56.6 kB)
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 DMCH · Feb 17, 2015 at 03:18 PM 0
Share

Thank you. The parent with scrollrect and mask was already in place. Was missing the layout element, and it's much closer to what is needed now. If you would like to convert your comment to an answer, we can close this one off.

One more thing, if you happen to know off hand. I'd like to keep the display area panel with the gridlayout at the full size of its parent by default, and increase its height only when the number of rows exceeds the number which can be displayed without scrolling.

alt text

Any ideas?

inventory-scene-new.png (48.7 kB)

1 Reply

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

Answer by Mmmpies · Feb 17, 2015 at 02:48 PM

Not totally clear what you want but I'd guess you need a parent panel for your inventory panel with a ScrollRect Component on it and a Mask.

Add a Content Size Filter to the inventory panel and set the prefabs to have a Layout Element with a minimum height/width set.

The panel should expand to fit items and the scroll rect will allow it to scroll.

You probably want to restrict movement to just vertical but that's up to you.

EDIT

Sorry, working on a very small screen so not always easy to see. I don't currently have access to Unity, hence the phone being used but...

I bet if you put a layout element on the panel itself you could set its min size with that.

You should be able to do this via code if the aspect ration/resolution is likely to change. Just find/add the Layout Element when the menu opens and set the minimum to be the size of the parents x/y.

Can't test it but it works alright in my head!

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

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

21 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

Related Questions

GridLayout dynamic cell size based on object count 0 Answers

Height Value of Rect Transform cannot be changed via script 1 Answer

uGUI Vertical Layout Group stretching objects 2 Answers

I don't understand "Child Force Expand" on uGUI 2 Answers

2x2 grid instead of 1x1 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