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!
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
Panel Component configuration
Container component configuration
Output window
Let me know if you need more assistance.