- Home /
Change size of the new UI rect transform using scripts
Hi!
I need to change the width of my rect transform using a script. But I can't find any way to do it. How do I do it?
Also, if you have no idea what I am talking about, get the new Unity 4.6.
Thanks in advance!
Answer by Omberone · Aug 21, 2014 at 09:38 PM
rectTransform.sizeDelta = new Vector2( yourWidth, yourHeight);
I want my UI to be placed at Left=0 Right=0 PosY=0 PosZ=0 Height=75
The uGUI system uses position and sizeDelta for the positioning. Where the meaning of those values changes based on anchors.
It is well explained here http://unity3d.com/learn/tutorials/modules/beginner/ui/rect-transform
So @Ankit Priyarup Left=position.x Right=sizeDelta.x PosY=position.y PosZ=position.z Height=sizeDelta.y
@aeroson I don't see a "pos" property on RectTransform - is there another one that you mean?
Your answer
Follow this Question
Related Questions
Convert Input.mousePosition to RectTransform pivot position 2 Answers
How to change the Top and Bottom (rect.yMin and yMax) properties of a rectTransform, in a script? 2 Answers
UI How to configure Left And Right. 1 Answer
[Unity 4.6 Beta] Rect Transform Position (New UI System) 7 Answers
Questions about UGUI Rect Transform Anchors. How to make UI objects scale, correctly, with screen? 1 Answer