- Home /
Using scripting #if define symbols in DLLs
Hi,
I created a new Debug DLL and imported it into the Plugins folder. Everything works fine except that scripting define symbols which are defined in Unity aren't picked up inside the DLL. The DLL code contains this:
public static class Debug
{
public static void Check()
{
#if !DEBUG_OUTPUT_OFF
UnityEngine.Debug.Log("Debug output is ON");
#else
UnityEngine.Debug.Log("Debug output is OFF");
#endif
}
}
In Unity, I've set DEBUG_OUTPUT_OFF for the current build platform, but calling this:
Debug.Check();
#if DEBUG_OUTPUT_OFF
Debug.Log("Output seems to be off in Unity");
#endif
...produces this output:
Debug output is ON
Output seems to be off in Unity
So is there a way to make Unity's scripting define symbols available to DLL code?
Seems you need to enable debug. Place your player in Development mode in Build Settings, then enable Script debugging.
Or are you saying you have already done this and its not working?
How do you know its a problem with symbols?
Answer by Dave-Carlile · Jul 23, 2015 at 12:53 PM
The defines are compile time things. Once you compile your code, they don't exist, and the code that they filter out doesn't exist.
Your plugin dlls are already compiled outside of Unity. That means they don't and can't know anything about compile conditions you've set up.
What are you trying to do?
I'm trying to make the DLL code sensitive to a define symbol defined in Unity. I'm sure that in a previous project, exactly this kind of setup worked, with some small additions. I guess I need to rebuild the DLL with the same symbols every time I Build&Run through Unity? $$anonymous$$aybe by adding something to the build postprocess? Or preprocess?
Yes you would need to rebuild the dll. I know you can something post process with Unity, but I'm not sure about pre-process.
Your answer
Follow this Question
Related Questions
Cant link PLUGIN.DLL with PLUGIN-EDITOR.DLL 1 Answer
Unity plugins 0 Answers
MonoBehaviour from DLL in AssetBundle Reflection problem 3 Answers
Referencing a DLL in C# 0 Answers
Access Multiple Camera Streams 0 Answers