Search Unity

Layout Group - Layout Element taking multiple spaces?

Discussion in 'UGUI & TextMesh Pro' started by PeteMichaud, Aug 8, 2015.

  1. PeteMichaud

    PeteMichaud

    Joined:
    Jul 11, 2015
    Posts:
    25
    I'm using a horizontal layout group to manage some pieces of my UI. My screen is designed to be divided into 3 sections, so the layout group works great for that. The problem is when a screen has 2 panels, one of which is supposed to occupy 1/3rd of the space, and the other is supposed to occupy 2/3rds of the space.

    I've been trying to use the Layout Element to set the preferred width and the flexible width, but it's not giving me the results I want.

    Ideally I'd have a setting on the Layout Element that let me specify how large the given element was in terms of how many "slots" this elements should occupy.

    In my example above I'd have 2 panels in my horizontal layout, one of which would take up the default of 1 slot, while the other took up 2 slots, forcing the panels to size as though there were 3 elements in the layout, with one of the panels spanning 2 of the 3 slots.

    Is there an easy way to do this already? If not, could someone help me with the code I'd need to write?