#define directive in UnityScript

For whatever reason, I am unable to add the #define directive in my UnityScript code.

The script compiles without the directive, but with the directive, it gives the error BCE0044: expecting 'p', found 'd'. on the line of the directive, referencing the second character of the line. The code I have is this:

#define KEY_NOSCRIPT

The line is located at the top of my script right after a #pragma strict. I have checked, and the order of the directives does not matter, nor does the presence of #pragma.

Is the #define directive supported in UnityScript?

1 Answer

1

It’s not supported in Unityscript.

Didn't know that. That's another good reason to forget JS and use C# instead.

Were a couple of years later, so I a, wondering if got supported in a update?

Nope.

However even when you can't use #define you can now define such constants "globally" for your whole project in the [player settings dialog][1]. It's called "Scripting Define Symbols". See the [Platform Dependent Compilation page][2] for more details. [1]: http://docs.unity3d.com/Manual/class-PlayerSettings.html [2]: http://docs.unity3d.com/Manual/PlatformDependentCompilation.html