I want to use a construct like this C# sample:
#if UNITY_IPHONE
// Get input using iPhone accellerometer
#endif
BUT I’d like to do it in Javascript. It does not work.
Does Javascript support conditional compilation ? If so does anyone know the syntax ?
Compiler directives do not exist in Unity
Not in JS nor in C# actually unless they were added with 2.5
I should say at least it would be new to me as this is a commonly asked question.
Its one of two common features from .NET that are not usable in unity (the other feature is namespaces which are also a no go within unity scripts)
There is a thread:
http://forum.unity3d.com/viewtopic.php?t=15650&highlight=ifdef
Than indicates it works in C#, and I did a quick test in a C# script and it seems to work - at least the script compiles with no errors.
Me too…one for the wishlist.
–Eric
I did a quick test in Unity 2.5 and Unity 2.1 and Unity iPhone 1.0.1 and the syntax compiles under C# (I didn’t test if its actually working just that #if … #endif can be in a script and it compiles with no errors).
I raised an enhancement request via the Help->Report a problem (FogBugz) so maybe something will happen for Javascript:
http://intra.unity3d.com/fogbugz/default.asp?169862_vd7686lq
The workaround, perhaps obviously, is to re-code my input handler in C#.