Text Auto Resizer

📏 TextAutoResizer Class

Automatically resizes TextMeshProUGUI components to fit their text content.

Namespace: Esper.FeelSpeak.UI.UGUI Inherits from: MonoBehaviour Type: class Requires: TextMeshProUGUI


📦 Fields

Access
Field
Type
Description

private

tmpText

TextMeshProUGUI

The TextMeshProUGUI component to resize.

private

rectTransform

RectTransform

The RectTransform component for size adjustments.


🧰 Methods

Access
Method
Returns
Description

private

Awake()

void

Initializes components and subscribes to TextMeshPro text change events.

private

Start()

void

Performs initial text resize on component start.

private

OnDestroy()

void

Unsubscribes from TextMeshPro text change events on destruction.

private

OnDisable()

void

Unsubscribes from TextMeshPro text change events when disabled.

private

OnEnable()

void

Resubscribes to TextMeshPro text change events when enabled.

private

OnApplicationQuit()

void

Unsubscribes from TextMeshPro text change events on application quit.

private

OnTextChanged(Object)

void

Handles text change events and triggers resize if the changed object matches this text.

private

ResizeToFitText()

void

Resizes the RectTransform height to match the text's preferred height.

Last updated