I am creating a health/stamina system in my Unity 2D game project, and I am trying to create a custom layout using the built in Grid/Horizontal/Vertical Layout Group components. The layout I am aiming to achieve will look similar to this image:
- Currently, the layout I have implemented has the (heart/crystal) prefab being instantiated horizontally one after another, as you can see in the very last image in this post. I am currently only using a "Grid Layout Group" component on a UI Image object (HeartHolder), which holds the actual cloned "heart" prefab(s) ("Heart" through "Heart (3)"). Some snips of these GameObjects and their Components are provided below. If you need to see the script(s) I can provide those as well, but theres really nothing special going on in them; basically the prefabs just get instantiated inside the HeartHolder object as children.
Heart Prefab Manager (HeartHolder) and related Heart Prefabs
HeartHolder (Manager) Components
Instead of instantiating the prefabs side by side (seen in the photo below), I want to add them diagonally from the last instantiated "heart". Really I'm mostly lost on where to start looking for information regarding this issue, as my previous searches haven't yeiled the results I want.
Any sort of links you can provide for my own learning, or keywords I can use to get my search started on this topic would be greatly appreciated!
How "Hearts" are currently Instantiated
I have tried using multiple different search terms/ keywords to look for solutions already given to this problem. The last phrase (... honeycomb ui layout) returned some tutorials on how to create levels with a hexagonal grid, but they dont use UI layout components (obviously) they use grid components. Is there a way to achieve the effect I want with Layout Components?
Terms Used:
- how to indent a row in a grid layout unity 2d
- change x-axis offset of Grid Layout row in unity
- unity 2d how to create honeycomb ui layout
I have not tried this yet, but I would assume if I put an empty child object under HeartHolder with a horizontal layout group, I could increase the padding on the left side of the object, and then alternate between the two objects when instantiating the heart prefabs, which would achieve the illusion of having the two rows offset horizontally, but that doesnt feel like the most efficient way to achieve such an effect.