In Unity, how can I programmatically control what source code is compiled?
I have a script with various BuildPipeline.BuildPlayer
calls, allowing me to build all versions of my game. However, I'm using the AVPro Video asset to play video, and it doesn't support 32bit Mac. As such, I need to fall back other video playing code on 32bit Mac. There's no preprocessor directive to differentiate 32bit OSX (like you can do for other platforms https://docs.unity3d.com/Manual/PlatformDependentCompilation.html ).
However, since I'm building each version in sequence, it seems like I should be able to set some state so that during compilation, the right code is used. I tried this:
VersionHandler.onMac32 = true;
BuildPipeline.BuildPlayer(levels, path, BuildTarget.StandaloneOSXIntel, BuildOptions.None);
VersionHandler.onMac32 = false;
And then checking that static variable in game. However, that static is "never set", presumably because the the state of the variable during compilation doesn't affect the value at runtime. Is there any other way I can "get at" the compiled code and set a flag for certain builds?
As a fallback, I can manually swap code in every time I build for OSX 32-bit, but I'd prefer not to do that.
#if UNITY_32
and#if UNITY_STANDALONE_OSX
doesnt work? \$\endgroup\$