Re-sizing a Canvas at runtime

So I have been trying to figure out how to resize a canvas via code… This is what I did and I thought it would work but it appears to hate me.

RectTransform CanvasTransform = (RectTransform)Canvas.GetComponent ("RectTransform");
        CanvasTransform.rect.Set (100, 100, 100, 100);

Anyone know how bad I am doing it wrong?

Thanks in advance!

what type of Canas are you using? Only World Space can be changed.

It is a World Space Canvas

I figured it out

Setting the SizeDelta property to a new vector2 will resize the canvas :smile: