I’ve been trying to following examples on how to use sizeDelta to change the height of a Text box via code, and although the following does show the change to “height” via Debug.Log, the change in height doesn’t apply to the object itself, so on each pass it pulls in the same height value, adds 2, but then this doesn’t seem to be set on the text box’s RectTransform during runtime. On the next pass it is back to the default values and goes no further.
Any ideas?
public Text output;
Vector2 rectSize = output.GetComponent<RectTransform>().sizeDelta;
rectSize = new Vector2 (rectSize.x, rectSize.y + 2);
EDIT:
added the following line to have it working - thanks to KrayZLogic for the correction.