- Home /
Preprocessor #defines and Conditional compilation in scripts
I've created a Debug class that uses the conditional attribute and placed it in an external assembly in Assets. All my other classes located in external assemblies work fine with it using my own #defines in the file headers. However, when I use the same #defines in my scripts the results are quite random. I can see the #defines are recognized in the scripts when run, but the calls to the Debug class don't happen (just like their wasn't a define in the file and they weren't compiled) after the scripts are compiled by Unity. There are also circumstances where the calls to the Debug class go through with the #define commented out. I'm thinking there must be some anomaly or bug with the Unity compiler when the methods attributed by the Conditional attribute were compiled previously by VS rather than being compiled at the same time as the calling methods.
What am I missing? Has anyone seen this before? I can find no sign of the issue on the forums. Appreciate any insight.
Are you defining your own #defines, or using the ones Unity supports? $$anonymous$$aybe you can post some code.
I've clarified my description per your question. I wouldn't know what code to post. As I indicated, the code in the debug class contained in the .dll works reliably when called from other .dll assemblies.