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

Viewed 125

I'm writing on some Unity modules.

Some of them depend on each other so I want to print out an error including the URL where to get the missing module(s).

I tried this:

#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

If the required module is missing the first line just prints out in the Unity3D console as expected

error CS1029: #error: 'This Module requires the RequiredModule module'

but the second line only prints

error CS1029: #error: 'Please get it from "https:'

  • I tried it with and without " and '

    this din't change anything but adding the " or ' to the ouput

  • I tried it like

    #error Please get it from "https:\/\/example.com" 
    

    but than it printed

    #error: 'Please get it from "https:\/\/example.com"'
    

How can I print an URL corrctly using the #error preprocessor in Unity?

Is there any escaping rule I'm missing?

1 Answers

You don't need any escaping at all. (Online demo.)

The message for an #error/#warning directive is (basically) anything after the directive and before the end of the line. This behaviour is also documented in the compiler source.

Related