0
votes

How can I adjust the TextMesh Pro container width/ height in Unity via script (C#)?

I've tried getting the TextContainer component to set .width, but either that's deprecated or I'm doing it wrong, but the TextContainer is null. I've also tried directly setting .width on the TextMeshPro component but that doesn't work either. Thanks!

1
can you show the code you tried? - BugFinder
did you try to instead set tmpText.GetComponent<RectTransform>().sizeDelta = new Vector2(desiredWidth, desiredHeihgt);? - derHugo

1 Answers

1
votes

sizeDelta gives you access to change width and height. I have just tried to make sure and it works.`

[SerializeField] private RectTransform _textRectTransform;

_textRectTransform.sizeDelta = new Vector2(_textRectTransform.sizeDelta.x * 2, _textRectTransform.sizeDelta.y * 2);