Skip to main content

Scripting Defines

In your game code you may wrap certain features in Scripting Defines; this code will only be compiled and run in certain conditions or platforms, such as specific Unity Versions.

Check out some more information about preprocessor directives and the list of defines supported by Unity.

If you wish to include certain scripting defines in your Unity Playworks Plugin builds, you can enter these pre-processor symbols into the Scripting Defines section in the Plugin UI, under Source code.

Example

#if  UNITY_2017_1_OR_NEWER
//...Your Awesome Code...//
#endif
If code wrapped with scripting defines exists in your code, which is required in your Unity Playworks Plugin build you should also include them in the `Scripting Defines` tab in the Plugin UI. Otherwise they wont be compiled.

Then include the name space inside the Unity Playworks Plugin Window. Navigate to the Code section and the Scripting Defines tab.

plugin-ui-code

Although you are able to select which ones are to be picked up during compilation, Unity Playworks Plugin implements scripting defines default namespaces that are pre-included in the Unity Playworks Plugin engine: UNITY_LUNA; UNITY_BUPC; UNITY_5_4_OR_NEWER;

Unity Playworks Plugin respects specific Unity version for scripting defines.

Let's use an example to fully undestand it:

  • While the UNITY_2018 will function if you are running Unity 2018, this will be skipped when running another version like Unity 2019.