Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. We are looking for feedback on the experimental Unity Safe Mode which is aiming to help you resolve compilation errors faster during project startup.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Conditional compile

Discussion in 'Editor & General Support' started by fwalkerCirca, Nov 28, 2017.

  1. fwalkerCirca

    fwalkerCirca

    Joined:
    Apr 10, 2017
    Posts:
    57
    I really need some help as I have been trying to get this working for way to long. I got Log4Net compiling and working great on the editor, and on PC/Mac/L build. I now need to make sure that the code is not compile in the WebGL build. For starters because it uses System.Configuration which WebGL does not like, and also because we don't want additional log code in WebGL.
    So,
    Can someone give me some ideas of how to do this?
    I stupidly figured that if the code was not referenced it would not be built. That is not the case. Then I figured I would but it in the editor folder and have it only compile in editor mode. Problem is I can't call the code from outside the editor. So what else I can do? I hear of the .rsc files but there is no documentation on how to used them other than to set global defines.
    The Log4Net comprises of some code (that I can pack up in a .dll again) I had to make some changes. And then a wrapper file, that used global defines to instantiate the logger or use the simple Debug.log calls.
    ANY help please? .... :(
     
  2. Zenix

    Zenix

    Joined:
    Nov 9, 2009
    Posts:
    207
  3. fwalkerCirca

    fwalkerCirca

    Joined:
    Apr 10, 2017
    Posts:
    57
    Yep, I saw that. But I am trying to exclude a set of files.
     
  4. fwalkerCirca

    fwalkerCirca

    Joined:
    Apr 10, 2017
    Posts:
    57
    Ohhh, I am so close. I will answer my own problem in case someone needs this.
    If we click on the .dll (so yes the code needs to be in a dll) we can assign Plugin Settings and tell Unity what platform to used the .dll on See https://docs.unity3d.com/Manual/PluginInspector.html

    So PERFECT! :) That solved my problem of how to exclude the Log4Net.dll from the WebGL build.

    Now I have other problems related to defines, specifically for the editor compilation. We can define defines for different compilations. PC/MAC/Linux and WebGL for example! So far so great,,, But what about for the Editor compilation. I would like to define LOG4NET_LOG for the editor version and the PC/MAC/Linux versions ONLY ! But I don't see a way to declare defines for the EDITOR! :( ... I don't want a GLOBAL in the .rsc file because I don't want it defined for WEBGL!!

    Help?

    Sooooo close.
     
unityunity