Search Unity

4 UI elements stretch across screen

Discussion in 'UGUI & TextMesh Pro' started by TheRaider, Feb 16, 2015.

  1. TheRaider

    TheRaider

    Joined:
    Dec 5, 2010
    Posts:
    2,250
    I have 4 UI elements (slider, button, button, text) and I am trying to make them use the width of the screen. Currently they just anchor to the centre and leave space when I go from iphone 5 to ipad in view.

    Could someone give me some tips on to make this stretch?
     
  2. BinaryX

    BinaryX

    Joined:
    Aug 4, 2014
    Posts:
    55
    Put them in an empty game object, anchor the empty game object to the sides of the screen, put "Horizontal Layout Group" component on the empty game object and then on each element inside put "Layout Element" component. Then change spacing, padding and other setting accordingly.
     
  3. TheRaider

    TheRaider

    Joined:
    Dec 5, 2010
    Posts:
    2,250
    Wouldn't that only work if they were the same size?
     
  4. TheRaider

    TheRaider

    Joined:
    Dec 5, 2010
    Posts:
    2,250
    Was actually pretty simple in the end. Just put the anchor points to the corners of each object so they were %'s