Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

UI Elements not stretching properly

Discussion in 'UGUI & TextMesh Pro' started by Nothke, Sep 1, 2014.

  1. Nothke


    Dec 2, 2012
    I wanted to make a simple platformer touch input for Android, and thought it would really easy to make this as UI buttons now with the new UI by making them invisible.. Well, instead of it being really simple it happened to be bonkers. I've put my buttons to stretch and placed them on canvas, now intuitively I thought that the buttons should literally stretch together with height and width.. But they don't!

    I set them up properly, anchors on edges, stretch..

    But when I reduce the width of the game window, the buttons get smaller by double, instead of keeping with the width of the canvas. At one point buttons will flip around after they pass into negative width. On the other hand when I increase the size, the stretch and eventually overlap. The same goes if you put buttons vertically.

    Eventually, I wanted to resize the buttons from code, but the TransformRect.rect is read only, unfortunately.

    I have spent 2 hours trying to figure this out, but I can't... Is there something I am doing wrong?
  2. runevision


    Nov 28, 2007
    Hi. The stretch options don't work the way you describe. Have a look at the page in the manual bundled with beta 18 called "Basic Layout".