我正在写一些Unity模块。
其中一些相互依赖,所以我想打印出一个错误,包括获取丢失模块的URL。
我尝试过:
#if !THIS_MODULE
#define THIS_MODULE
#endif
#if !REQUIRED_MODULE
#error This Module requires the RequiredModule module
#error Please get it from "https://example.com"
#endif
如果缺少所需的模块,则第一行只需按预期在Unity3D控制台中打印出来
error CS1029: #error: 'This Module requires the RequiredModule module'
但仅打印第二行
error CS1029: #error: 'Please get it from "https:'
我尝试了使用"
和'
除了在输出中添加"
或'
之外,其他什么都没有改变
我尝试过
#error Please get it from "https:\/\/example.com"
但不是印刷的
#error: 'Please get it from "https:\/\/example.com"'
如何在Unity中使用#error
预处理器正确打印URL?
我缺少任何转义规则吗?
答案 0 :(得分:2)
您根本不需要任何转义。 (Online demo。)
#error
/ #warning
伪指令的消息(基本上)是该伪指令之后和行尾之前的任何内容。
此行为也是documented in the compiler source。