強火で進め

このブログではプログラム関連の記事を中心に書いてます。

RectTransform プロパティの width や height の値をプログラムから変更する方法

RectTransform の sizeDelta に値を設定する事で width や height の値を変更可能です。

RectTransform rt = UICanvas.GetComponent (typeof (RectTransform)) as RectTransform;
rt.sizeDelta = new Vector2 (100, 100);

参考情報

Modify the width and height of RectTransform | Unity Community
http://forum.unity3d.com/threads/modify-the-width-and-height-of-recttransform.270993/