当前位置:网站首页>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");
边栏推荐
- [C # notes] reading and writing of the contents of text files
- 传感器:DS1302时钟芯片及驱动代码
- 15million employees are easy to manage, and the cloud native database gaussdb makes HR office more efficient
- MySQL execution process and sequence
- 【Unity】升级版·Excel数据解析,自动创建对应C#类,自动创建ScriptableObject生成类,自动序列化Asset文件
- 建议收藏!!Flutter状态管理插件哪家强?请看岛上码农的排行榜!
- Processing image files uploaded by streamlit Library
- 1个月增长900w+播放!总结B站顶流恰饭的2个新趋势
- [unity] upgraded version · Excel data analysis, automatically create corresponding C classes, automatically create scriptableobject generation classes, and automatically serialize asset files
- UC伯克利助理教授Jacob Steinhardt预测AI基准性能:AI在数学等领域的进展比预想要快,但鲁棒性基准性能进展较慢
猜你喜欢

Livox激光雷达硬件时间同步---PPS方法

豆瓣平均 9.x,分布式领域的 5 本神书!

Word wrap when flex exceeds width

解密函数计算异步任务能力之「任务的状态及生命周期管理」

Twenty or thirty thousand a leaf? "Yang Mou" behind the explosion of plant consumption

A new path for enterprise mid Platform Construction -- low code platform

【Unity】升级版·Excel数据解析,自动创建对应C#类,自动创建ScriptableObject生成类,自动序列化Asset文件

Introduction to FLIR blackfly s industrial camera

1个月增长900w+播放!总结B站顶流恰饭的2个新趋势

红外相机:巨哥红外MAG32产品介绍
随机推荐
Zabbix 5.0:通过LLD方式自动化监控阿里云RDS
【服务器数据恢复】raid损坏导致戴尔某型号服务器崩溃的数据恢复案例
猿桌派第三季开播在即,打开出海浪潮下的开发者新视野
老板被隔离了
大咖云集|NextArch基金会云开发Meetup来啦!
ZABBIX 5.0: automatically monitor Alibaba cloud RDS through LLD
FLIR blackfly s industrial camera: auto exposure configuration and code
Stm32f4 --- PWM output
MySQL execution process and sequence
Flir Blackfly S USB3 工业相机:计数器和定时器的使用方法
Introduction to the internal structure of the data directory of PostgreSQL
4--新唐nuc980 挂载initramfs nfs文件系统
argo workflows源码解析
centos8安裝mysql報錯:The GPG keys listed for the “MySQL 8.0 Community Server“ repository are already ins
Centos8 install MySQL 8.0 using yum x
Tips for web development: skillfully use ThreadLocal to avoid layer by layer value transmission
压缩 js 代码就用 terser
豆瓣平均 9.x,分布式领域的 5 本神书!
1--新唐nuc980 NUC980移植 UBOOT,从外部mx25l启动
阿里云中间件开源往事