ObjectiveMain objective of this blog post is to give you an idea about How to work with Independent Vertical Layout and Independent Horizontal Layout in Unity UI.
The Vertical Layout Group component places its child layout elements on top of each other. Their heights are determined by their respective minimum, preferred and flexible heights according to the following model:
- The minimum heights of all the child layout elements are added together and the spacing between them is also added. The result is the minimum height of the Vertical Layout Group.
- The preferred heights of all the child layout elements are added together as well as the spacing between them is added. As a result you will get the preferred height of the Vertical Layout Group.
- If the Vertical Layout Group is at its minimum height or smaller, all the child layout elements will also have their minimum height.
- The closer the Vertical Layout group is to its preferred height, the closer each child layout will get to their preferred heights.
- If the Vertical Layout Group is taller than its preferred height, it will distribute the extra available space proportionally to the child layout elements according to their respective flexible heights.
Here I have taken a resolution independent example using vertical layout.
Step 1 Create Panel
Create panel from Create ⇒ UI ⇒ Panel and name it Panel - Vertical Layout.
Step 2 Create one more Panel
Under the Vertical Layout Panel and name it to Panel - Item Container
Step 3 Create Panel item under the Panel
Item Container and add some buttons and text in the panel.
Step 4 Duplicate the Panel Items
Step 5 Check the Output
Check the output by changing the screen resolutions. Like Bellow is 600 * 1024 resolution output, you can check it in all the resolutions. It will always give the best fit output in every resolution.
I hope you find this blog very helpful while working with Independent Vertical Layout or Independent Horizontal Layout in Unity UI 4.6. Let me know in comments if you have any question regarding Unity UI.
I am 3D game developer with an aspiration of learning new technology and creating a bright future in Information Technology.