unity modify recttransform width code example
Example 1: set width of rect transform unity
rectTransform.sizeDelta = new Vector2(50, 50);
Example 2: how to change the size of ui in script unity
_image.rectTransform.sizeDelta = new Vector2(width, height);