- Home /
Possible to only compile some scripts?
I've got a set of "library" classes and extension methods I use (published on github). I use git to version my projects, and I'd like to use git submodules to manage "importing" the unity-utilities repository into my current repository.
The problem is that parts of my repository depends on another library (AngryAnt's Path in this case), so it doesn't compile if that library is not present in the project. Not all of my projects include Path - and these projects don't need this part of unity-utilities.
So here's the challenge: How do I prevent it from compiling these (unused) classes when I'm using it in a project without Path? I can't comment out the code, because it's shared code. I tried checkout the submodule outside of Assets and symlinking the parts I use into Assets, but symlinks are not supported on OS X.
Any other ideas?
Answer by whydoidoit · May 31, 2012 at 09:45 AM
How about doing some conditional compilation and set a #if around the code that is only some compiled on occasion - then you could set the #define somewhere and get it switchable? WARNING: I haven't used this but see this thread in which some very smart people discuss a way of getting the #define globally for your project.
This seems like just what I needed - I didn't know there was a way to have global defines. The last comment on that thread (page 2) seems to indicate this doesn't work for real "builds" in 3.5, just for editor, so I'll have to investigate it. :-)
I'll mark your answer as accepted if it works for real builds too. Thanks!
Yeah, this is just what I need - I'm adding #if !NO_PATH .. #endif around the code and then I can just do -define:NO_PATH in the smcs.rsp. See my comment here: http://forum.unity3d.com/threads/71445-How-To-Set-Project-Wide-pragma-Directives-with-JavaScript?p=940327&viewfull=1#post940327
Thanks!
Your answer
![](https://koobas.hobune.stream/wayback/20220613072158im_/https://answers.unity.com/themes/thub/images/avi.jpg)