From 2419d3d29ce0803e9ed982dbafeecaa99abb09b6 Mon Sep 17 00:00:00 2001 From: sanyoni Date: Wed, 25 Feb 2026 14:27:41 +0900 Subject: [PATCH] fix: prevent text loss in UITextEllipsisOverflow --- .../Runtime/Foundation/UITextEllipsisOverflow.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Assets/UnityDebugSheet/Runtime/Foundation/UITextEllipsisOverflow.cs b/Assets/UnityDebugSheet/Runtime/Foundation/UITextEllipsisOverflow.cs index 0296486..8c22511 100644 --- a/Assets/UnityDebugSheet/Runtime/Foundation/UITextEllipsisOverflow.cs +++ b/Assets/UnityDebugSheet/Runtime/Foundation/UITextEllipsisOverflow.cs @@ -15,7 +15,8 @@ public class UITextEllipsisOverflow : UIBehaviour [SerializeField] [Tooltip("If set to true, the text will actually be overwritten in EditMode.")] private bool _applyInEditMode = true; - private string _textValue; + private string _textValue = string.Empty; + private string _originalTextValue = string.Empty; protected override void Awake() { @@ -24,6 +25,7 @@ protected override void Awake() { _text = GetComponent(); _textValue = _text.text; + _originalTextValue = _text.text; } } @@ -32,8 +34,9 @@ private void Update() if (_text.text == _textValue) return; - _textValue = _text.text; + _originalTextValue = _text.text; Apply(); + _textValue = _text.text; } protected override void OnRectTransformDimensionsChange() @@ -57,12 +60,12 @@ private void Apply() if (!IsActive() || _text == null) return; + var text = _originalTextValue; + var rectTransform = _text.rectTransform; var generator = _text.cachedTextGenerator; var settings = _text.GetGenerationSettings(rectTransform.rect.size); - generator.Populate(_text.text, settings); - - var text = _text.text; + generator.Populate(text, settings); if (rectTransform.rect.width <= 0 || rectTransform.rect.height <= 0) // Do nothing because the layout seems not to have been built yet.