如何在Unity3D中的c##error预处理器中打印URL?

时间:2018-09-21 12:26:04

标签: c# unity3d preprocessor preprocessor-directive

我正在写一些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?

我缺少任何转义规则吗?

1 个答案:

答案 0 :(得分:2)

您根本不需要任何转义。 (Online demo。)

#error / #warning伪指令的消息(基本上)是该伪指令之后和行尾之前的任何内容。 此行为也是documented in the compiler source