DOText에서 \n가 엔터로 처리되지 않을 때

 

데이터베이스에서 주고 받을 때 \n 을 엔터로 받아서

바로 Text에 입력해보면 rich Text 덕분에 엔터로 바로 적용된다.

 

그런데 DOText를 사용하는경우 엔터로 적용되지않고 \n가 그대로 출력되는 현상이 있음.

 

string targetText = text.Replace("\\n", "\n");

 

타겟 텍스트를 위와같이 한번 처리해주면 정상출력됨.

 

 

나는 아래와 같이 확장 메서드를 만들어서 사용하고있음.

    public static string DOTextMy(this TextMeshProUGUI textUGUI, string text, float perCharTime = 0.03f, System.Action endAction = null)
    {
        string targetText = text.Replace("\\n", "\n");
        float duration = CalculateTextLength(targetText) * perCharTime;

        textUGUI.DOKill();
        textUGUI.text = "";
        textUGUI.DOText(targetText, duration).SetUpdate(true).OnComplete(() => endAction?.Invoke());

        return targetText;
    }

 

댓글

Designed by JB FACTORY