Unity3d read the text in CSV to Rich text line breaks do not recognize the problem

Source: Internet
Author: User

In the project to use the character text to do some information display, need to have color, font style, line wrapping and so on, Unity's Rich text can be used to do this kind of demand.

About the use of rich Text:

Http://docs.unity3d.com/Manual/StyledText.html

Although there is no mention of the "\ n" line break, it is actually supported.

Article transferred from Http://blog.csdn.net/huutu http://www.thisisgame.com.cn

There was a problem today when reading the contents of the CSV into Rich text.


is the content in the CSV, which is directly assigned to Text after reading. But there is no line break after running.


As it is, is Rich Text not supporting "\ n" for a newline?


Writes the contents of the CSV directly to the code, and assigns them to Text.

Found to be OK.

Article transferred from Http://blog.csdn.net/huutu http://www.thisisgame.com.cn

Suspicion is a problem with CSV. So the breakpoint to see what the code read out, sure enough to find the problem:


After reading the contents from the CSV, the original "\ n" became "\\n".

Personally think that in Excel, in order to "\ n" as the normal character processing and added "\" To mark the following is the normal character content.


Now that we know the reason, it is convenient to solve it. Just replace "\\n" with "\ n".

M_mainnoticetext.text = Noticeinfo. Title.replace ("\\n", "\ n");

article transferred from Http://blog.csdn.net/huutu http://www.thisisgame.com.cn

Unity3d read the text in CSV to Rich text line breaks do not recognize the problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.