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
3
Question by Tastman · Jun 04, 2015 at 02:09 PM · uigrid

Smooth transition of objects in Grid Layout Group

I have constructed a UI shop element using a Grid Layout Group on a canvas. On the grid object I have a script with an array of button-prefabs which can instantiate into the grid. When I click a button, the button is destroyed and all of the buttons below are moved up one step.

It looks like this:

alt text

What I want to do is make the second and subsequent objects have a smooth transition when moving up the grid.

I could use a function to interpolate the entire grid object to move it up, but that would be a sloppy solution. (I would have to force the player to buy the first item)

I can't change the position value of the child objects in the grid. Is this effect somehow possible with grid layout groups?

grid.gif (227.4 kB)
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 kubasteve · Jul 20, 2015 at 04:01 PM 0
Share

Hi, I am trying to get a similar system like this into my game. Did you ever figure out how to add a smooth transition in your grid?

avatar image Tastman · Jul 20, 2015 at 08:11 PM 0
Share

Not really the way I wanted to. There seems to be very little coverage on grid layout groups in Unity.

What I ended up doing was to dynamically change the height of the grid's rect transform as items were added. I measured the height of the buttons in the grid, and had a bit of code telling it "for each item in the grid, increase grid height by x with a smooth lerp".

The grid was set up as a vertical, upper left child alignment, so when an item was added it would first be added outside of the screen (as it would not yet fit inside the grid), and as the grid's height started increasing, the first item would follow along the top of the grid, and the new item popped up underneath.

Likewise, when an item was clicked and removed, the grid height would decrease and the items inside would follow.

It looks like this: alt text

Not sure if that's a kind of solution you could go for but I hope it helps.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by kubasteve · Jul 21, 2015 at 09:26 PM

Hi again,

So I actually I got something that works really nicely. I based my stuff off this video tutorial series: https://www.youtube.com/watch?v=bMuYUOIAdnc. Pretty much what the guy in the videos does is he creates invisible placeholders and puts those in place to where the cell was and he does some rearranging on the grid by modifing all the childrens sibling index. In my solution I do it somewhat similarly but I have added DOTweens so everything has a smooth transition.

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 Tastman · Jul 24, 2015 at 02:51 PM 0
Share

That's a neat technique. Will look into DOTween aswell, might come in handy. Thanks!

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Making a scrollable list with ScrollRect, GridLayoutGroup and ContentSizeFitter. How to make it start at the top? 1 Answer

Unity Check overlap of rect works except if in gridlayoutgroup 0 Answers

Adding a string to grid layout group 1 Answer

Grid and Canvas react on mouse events simultaneously 0 Answers

How do I get the grid layout component? 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