+1 vote

I've recently delved into creating EditorPlugins to make it easier to edit custom resources I've created. Unfortunately, having any class that extends EditorPlugins prevents me from exporting my projects - I presume because Godot is linking against a library that does not include a symbol for the EditorPlugin class for exports. So I would like to find a way to comment out my EditorPlugin when exporting my projects but still have it there when I compile for debug so that my plugin can still be used by the editor.

The C# preprocessor seemed to be the answer to this problem and the docs even say that I can define my custom flags by adding a keyword to the Export/Features panel:
https://docs.godotengine.org/en/latest/tutorials/scripting/c_sharp/c_sharp_features.html#preprocessor-defines

Unfortunately, this is not working for me. I added the keyword 'export' to the Features panel and used #if GODOT_EXPORT to try and use it, but the flag seems to be ignored.

    #if GODOT_EXPORT
        richTextLabel.BbcodeText = "release";
    #else
        richTextLabel.BbcodeText = "debug";
    #endif

How do I set my custom flag? Is there some other way to not have this code compiled into any exported version of my project?

Godot version v3.4.stable.mono.official [206ba70f4]
in Engine by (124 points)

1 Answer

0 votes
Best answer

Try this way:
enter image description here
enter image description here

by (243 points)
selected by

How do I have that set only when I export? That looks like it will be set regardless of the target.

i think there is a DEBUG flag that you can use.

#if DEBUG
#define NEW_FLAG
#endif

That does seem to work to solve this problem. Still, it would be nice to know why the Features section does not seem to be working.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.