Are there some built in defines you can use in your scripts with regards to the target platform? or can you insert some defines somewhere for the preprocessor.
Im asking because Im making a plugin and I need to “load” different versions depending on the target platform?
//Per
This is how I understand it the #define preprocessor directive
http://www.switchonthecode.com/tutorials/the-csharp-preprocessor-an-overview
I use C#, I am not sure if it is the same with UnityScript
You will need to compile each target.
#define STANDALONE
//#define WEBPLAYER // commented out
// common code
#if STANDALONE
// code for standalone
#endif
#if WEBPLAYER
// code for webplayer
#endif
Also look at this :
file:///Applications/Unity/Unity.app/Contents/Documentation/Documentation/ScriptReference/Application-platform.html
You do not need #defines for that. Just place both Windows and OSX (universal) versions to Plugins directory. Use the same name (naturally extension varies–bundle/dll). Unity will add the correct one to standalone player.
thx both of you.
Rom: I know how the preprocessor works, but I just didnt know how it was used in Unity (since it is actually here its compiled) so it would have been interesting if there were some way of (not runtime with app.platform, but compile time) detecting the build so you could make different versions of code, pretty much as you can with Visual Studio with different configurations.
Iankoski: thx that was pretty much what I wanted to know.
//Per
is there anything defined for iPhone, so I can do something like:
#if IPHONE
class A {}
#else
class A {}
#endif
Although this is not a compile-time thing, note that you still have Application.platform to go by.
Reviving this old thread. Is there anything like
#ifndef
//code
#endif
There is #if but i’m looking for the opposite of this. I really want to avoid having to add an empty if and then using the else block.
Note that in this case I absolutely do need the pre-processor macro because I want to make use of the iPhoneInput which doesn’t compile on PC systems.