Game Development Reference
In-Depth Information
5.
Set the Width of the HorizontalLayoutGroup GameObject to 300
( 3 children = 3 x 100 width children as it will auto resize its children
Rect Transforms ).
6.
Right-click the HorizontalLayoutGroup GameObject and add three child.
Image controls (UI | Image), I named them Child1 , Child2 , and Child3 .
( UI | Image ).
7.
Set the Source Image of each child to a Sprite of your choice (I borrowed the
Unity 128 x 128 logo as an example, which is included in the topic sample
assets download).
This would result in the following view:
An example showing 3 sprites arranged horizontally by the layout group
The resulting view shows three child Unity logos arranged side by side organized
by the Horizontal Layout Group component automatically.
This is a very basic example, but we will cover more advanced layouts later in
the topic.
Note: By default, the layout group will resize the child elements to fit
within the area defined by the group's Rect Transform , to alter this you
will need to either resize the group to fit its content or use Layout Element
or Content Size Fitter components described in the sections that follow.
The three 128 x 128 Unity logo's in this example got resized down
to 100 x 100.
 
Search WWH ::




Custom Search