[v2017.1.0f3]Canvas : Rect Transform Resize - Render Mode [Solved]

Hello,

Sorry if it’s a noob question, but when I try to resize my grille_canvas to fit in canvas, it didn’t worked.

I work with Unity v2017.1.0f3 in 2D.

I tried to change with this script:

rectTransform.sizeDelta = new Vector2( yourWidth, yourHeight);

that i found here [Change size of the new UI rect transform using scripts - Questions & Answers - Unity Discussions]
and here [RectTransform won't Resize - Questions & Answers - Unity Discussions]
but it didn’t found sizeDelta.

I also know this [user interface - Unable to Move the Canvas or Change Any of the Transform Values - Stack Overflow] so I tried other Render Mode like World Space but when I try any combination of Width/Height, it zoom anormally and in the same way.

Width:2048 - Height:1531

Width:6000 - Height:3000

So do you guys have a solution to resize my Grille_canvas?

Thanks in advance! :smile:

If you set up a child of a Canvas to have anchors set to stretch with no offsets, the child will automatically resize to fit the Canvas.

3157363--240173--Capture.PNG

Child RectTransforms are positioned and sized using anchors which are positioned relative to the parent.

Thanks for your answer but my Canvas (named Grille_Canvas) can’t be a child of something :confused:

btw: I found the answer of my problem, I didn’t know there were a setting were your can add your own resolution here

Seems that I can manually change the width and the height manually of the display in the render mode Screen Space - Overlay

Your Canvas is the parent, your Image should be a child object. My screenshot would be the settings of the child, which stretches to fit the size of the Canvas.

Those settings in the Game tab will let you preview what your UI will look like using different resolutions, so your Canvas will resize accordingly. That is not the resolution that your game will use in a build, necessarily. The game will still try to fit whatever aspect ratio it’s displayed on, with the Canvas resizing according to how you set it and its children up.