Search Unity

Layout Hexagonal Icons Flexibly

Discussion in 'UGUI & TextMesh Pro' started by uwdlg, Oct 14, 2020.

  1. uwdlg

    uwdlg

    Joined:
    Jan 16, 2017
    Posts:
    150
    Hi,

    I have hexagonal icons (oriented with points facing up) representing skills in a skill tree that I would like to arrange as follows:
    • skills that can only be unlocked in sequence shall be side by side from left to right.
    • different skills shall be "stacked" top to bottom with every second line offset so as to not waste space (think honeycomb). Note that this means the square Image components overlap.
    • The widest line of icons (i.e. with the highest count) shall determine the overall size: the icons' widths shall be expanded so that the available width is filled, the height shall be set so as to preserve the aspect ratio.
    Is there a way to get this done with the built-in layout groups? Or should I write a custom layout group / script to modify Layout Elements or something as needed?
    Also, putting an
    Aspect Ratio Fitter
    on children of a Layout Group produces a warning that the child should not have that component because its layout should be driven by the Layout Group. I don't see how to replicate its functionality though, can that warning be ignored in such a case? It seems to work, just feels wrong to ignore it.

    Thanks in advance