当前位置:网站首页>Untiy文本框的代码换行问题
Untiy文本框的代码换行问题
2022-07-06 18:43:00 【吴梓穆】
如果是我们主动指定换行,我们可以使用\n来换行
例如
infoText.text = "id:" + monitor.id + "\n" +
"cameraType:" + monitor.cameraType + "\n" +
"workshopName:" + monitor.workshopName+ "\n" +
"camerasIP:" + monitor.camerasIp + "\n" +
"camerasUser:" + monitor.camerasUser + "\n" +
"camerasPwd:" + monitor.camerasPwd + "\n" +
"camerasPort:" + monitor.camerasPort + "\n" +
"monitorName:" + monitor.monitorName+"\n"+
"region:"+monitor.region+"\n"+
"code:"+monitor.code
如果文字内容来自别处,比如从服务器下载,如果文字里自带 \n换行,直接把文字放进text里,\n会被识别为字符,而不会换行,这时因为Untiy非常好心的帮我们自动吧 \n替换为\n了(尽管你很确定你拿到的数据就是\n),所以我们要手动把\n替换为\n,防止被转义
例如
BookRequestResult bookResult = JsonConvert.DeserializeObject<BookRequestResult>(request.downloadHandler.text);
contentText.text = bookResult.data.book;
contentText.text = contentText.text.Replace("\\n","\n");
contentText.text = contentText.text.Replace("\\r","\r");
边栏推荐
- Centros 8 installation MySQL Error: The gpg Keys listed for the "MySQL 8.0 Community Server" repository are already ins
- 【Unity】升级版·Excel数据解析,自动创建对应C#类,自动创建ScriptableObject生成类,自动序列化Asset文件
- Metaforce force meta universe development and construction - fossage 2.0 system development
- 纽约大学 CITIES 研究中心招聘理学硕士和博士后
- Sensor: introduction of soil moisture sensor (xh-m214) and STM32 drive code
- [C # notes] reading and writing of the contents of text files
- Halcon knowledge: segment_ contours_ XLD operator
- The foreground downloads network pictures without background processing
- #yyds干货盘点# 解决名企真题:最大差值
- RC振荡器和晶体振荡器简介
猜你喜欢
[paper reading | deep reading] anrl: attributed network representation learning via deep neural networks
Flir Blackfly S 工业相机:通过外部触发实现多摄像头同步拍摄
Web3对法律的需求
FLIR blackfly s usb3 industrial camera: how to use counters and timers
老板被隔离了
Recommended collection!! Which is the best flutter status management plug-in? Please look at the ranking list of yard farmers on the island!
如何从0到1构建32Core树莓派集群
建议收藏!!Flutter状态管理插件哪家强?请看岛上码农的排行榜!
Zhang Ping'an: accelerate cloud digital innovation and jointly build an industrial smart ecosystem
[unity notes] screen coordinates to ugui coordinates
随机推荐
fiddler的使用
[C # notes] reading and writing of the contents of text files
Time synchronization of livox lidar hardware -- PPS method
【论文阅读|深读】ANRL: Attributed Network Representation Learning via Deep Neural Networks
Blackfly s usb3 industrial camera: buffer processing
Integrated navigation: product description and interface description of zhonghaida inav2
Seconds understand the delay and timing function of wechat applet
6 seconds to understand the book to the Kindle
String or binary data will be truncated
解密函数计算异步任务能力之「任务的状态及生命周期管理」
postgresql之整體查詢大致過程
XML to map tool class xmlmaputils (tool class V)
Word wrap when flex exceeds width
FLIR blackfly s usb3 industrial camera: how to use counters and timers
Blackfly S USB3工业相机:缓冲区处理
[unity notes] screen coordinates to ugui coordinates
FLIR blackfly s industrial camera: auto exposure configuration and code
激光雷达:Ouster OS产品介绍及使用方法
ZABBIX 5.0: automatically monitor Alibaba cloud RDS through LLD
张平安:加快云上数字创新,共建产业智慧生态