how to chnage the Scale propery of rect tranform unity 1

how to chnage the Scale propery of rect tranform unity

// To Change the "Scale" property use localScale, like this
// Change the numbers in the "()" to your choosen scale
public GameObject YourPanel;
YourPanel.GetComponent().localScale = new Vector3(newWidthUI, newHeightUI, 1);

// If you want to change it in pixels
public GameObject yourUI;
yourUI.GetComponent().sizeDelta = new Vector2(newWidthUI,newHeightUI);

Here is what the above code is Doing:
1. You are getting the RectTransform component of your UI element.
2. You are changing the sizeDelta property of the RectTransform component.
3. You are changing the localScale property of the RectTransform component.

Similar Posts