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

How to print an URL in a c# #error preprocessor in Unity3D?

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


如何使用 Unity 中的 #error 预处理器正确打印 URL?

是否缺少任何转义规则?

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

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