gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 12:20:20 26 4
gpt4 key购买 nike

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

我是否缺少任何转义规则?

最佳答案

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

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

关于c# - 如何在 Unity3D 中的 c##error 预处理器中打印 URL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52443750/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com