Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

521
Views
Can i make the children of my grid layout group not follow the hierarchy? (Unity)

Probably a stupid question but anyway: I have a grid layout for my inventory (Unity 2D 2020) and I would like it so when I pick up an item the inventory displays the items in the order that the gameobject is activated. Currently, if I have an inventory with the hierarchy order as apples, oranges and lemons it looks like this:

apples | oranges | lemons

And if I have no more oranges it looks like this:

apples | lemons

But if pick up an orange at a later time it pushes lemons to third and oranges goes back to being second place instead of being third.

Is there any way to make the grid layout follow the order the items are activated?

I hope this is clear - I suck at explaining things, I'm sorry.

Thank you!

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

From what I understood, you want to create inventory by sorting what items you get first.

In UI setup, you can have Parent GameObject, let's call it "Panel", with Grid Layout Groupcomponent and make prefab of that. Also make another Child GameObject of Parent and call it "Container" and make prefab of that too. Lastly you should have prefabs for Apple, Orange and Lemons.

The Panel will always be there in hierarchy but you will Instantiate each container when you have new item, for example if you get Apple, you will instantiate apple container inside Panel. Check if you have already instantiated apple container, if not then just add apple gameobject. Do this for other items as well. The instantiated container will always be next in UI.

Sharing some UI setup image I did. (This is only to make you understand)

UI Setup, showing Panel and Container

UI Setup, showing Panel and Container

Panel Component configuration

Panel Component configuration

Container component configuration

Container component configuration

Output window

Output window

Let me know if you need more assistance.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!