3
\$\begingroup\$

I insert a canvas, after that, I insert an image at center. Then, I want to stretch this image over this canvas, so I choose last option as below:

enter image description here

But the image doesn't stretch to fit the canvas, as you see: (in fact, image object doesn't change anything)

enter image description here

Please tell me how to make this image stretches over the canvas.

thanks :)

\$\endgroup\$
3
\$\begingroup\$

As the top notification says, in order to achieve the desired effect, you need to hold down ALT and SHIFT when clicking the stretch icon.

enter image description here

More info: http://docs.unity3d.com/Manual/class-RectTransform.html
Video: http://unity3d.com/learn/tutorials/modules/beginner/ui/rect-transform

\$\endgroup\$
  • \$\begingroup\$ too simple :D thanks :) I don't know why does Unity make us to do this ? If I choose without press Shift and Alt, are there any effects for this behavior ? \$\endgroup\$ – hqt Feb 25 '15 at 13:31
  • \$\begingroup\$ It is that way because maybe sometimes you want to set only the Anchor, or the Anchor and Pivot only. \$\endgroup\$ – Mihai-Andrei Dinculescu Feb 25 '15 at 13:42
  • 1
    \$\begingroup\$ To put that in a bit more context, Unity assumes that the way you have it looking on screen right now is the way you want it to look, so when you change an anchor setting, by default it updates the other settings to compensate & maintain the current appearance (rather than force you to go back and adjust those manually). This helps if you wanted to lay out some UI visually without thinking of stretching behaviour first, and then want to update the finished layout to stretch correctly. For other cases, they provided these modifier keys. \$\endgroup\$ – DMGregory Feb 25 '15 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.