Unity scripting symbol reference
A reference of the predefined scripting symbols Unity provides.
Read time 4 minutesLast updated 2 days ago
Platform symbols
Unity automatically defines certain symbols based on the authoring and build target platform. These are as follows:
Define | Function |
|---|---|
| Scripting symbol to call Unity Editor scripts from your game code. |
| Scripting symbol for Editor code on Windows. |
| Scripting symbol for Editor code in macOS. |
| Scripting symbol for Editor code on Linux. |
| Scripting symbol for embedded Linux. |
| Scripting symbol for QNX. |
| Scripting symbol to compile or execute code specifically for macOS (including Universal, PPC and Intel architectures). |
| Scripting symbol for compiling/executing code specifically for Windows standalone applications. |
| Scripting symbol for compiling/executing code specifically for Linux standalone applications. |
| Scripting symbol for compiling/executing code for any standalone platform (Mac OS X, Windows or Linux). |
| Scripting symbol for compiling/executing code for a dedicated server (macOS, Windows or Linux). |
| Scripting symbol for compiling/executing code for the iOS platform. |
| Scripting symbol for the Android platform. |
| Scripting symbol for the Apple TV platform. |
| Scripting symbol for the VisionOS platform. |
| Scripting symbol for Universal Windows Platform. |
| Scripting symbol for Universal Windows Platform. |
| Scripting symbol for Web. |
| Scripting symbol for calling Unity Analytics methods from your game code. |
| Scripting symbol for assertions control process. |
| Scripting symbol for enabling safety checks. |
| Scripting symbol for enabling instrumentation code paths, such as the profiler. |
Unity Editor version symbols
Unity automatically defines certain scripting symbols based on the version of the Unity Editor that you're currently using.
Given a version number (for example, 6000.0.33), Unity exposes three global scripting symbols in the following formats: , and .
X.Y.ZUNITY_XUNITY_X_YUNITY_X_Y_ZHere is an example of scripting symbols exposed in Unity 6000.0.33:
Define | Function |
|---|---|
| Scripting symbol for the release version of Unity 6, exposed in every 6000.Y.Z release. |
| Scripting symbol for the major version of Unity 6.0, exposed in every 6000.0.Z release. |
| Scripting symbol for the minor version of Unity 6000.0.33. |
You can also compile code selectively based on the earliest version of Unity required to compile or execute a section of code snippet. Following the same version format describd previously (), Unity exposes one global in the format (for example, ), that you can use for this purpose.
X.Y#defineUNITY_X_Y_OR_NEWERUNITY_6000_0_OR_NEWEROther symbols
The other symbols Unity defines are:
Define | Function |
|---|---|
| Defined when building scripts with support for C# 7.3 or newer. |
| Scripting back end #define for IL2CPP. |
| Defined when the target build platform supports VR. Doesn't imply that VR is currently enabled or that the necessary plug-ins and packages needed to support VR are installed. |
| Defined when building scripts against .NET 2.0 API compatibility level on Mono and IL2CPP. |
| Defined when building scripts against .NET 2.0 Subset API compatibility level on Mono and IL2CPP. |
| Defined when building scripts against .NET 2.0 or .NET 2.0 Subset API compatibility level on Mono and IL2CPP. |
| Defined when building scripts against .NET 4.x API compatibility level on Mono and IL2CPP. |
| Defined when building scripts against .NET Standard 2.0 API compatibility level on Mono and IL2CPP. |
| Defined when building scripts against .NET Standard 2.1 API compatibility level on Mono and IL2CPP. |
| Defined when building scripts against .NET Standard 2.1 API compatibility level on Mono and IL2CPP. |
| Defined when building scripts against .NET Standard 2.1 API compatibility level on Mono and IL2CPP. |
| Defined when building scripts against .NET Standard 2.1 API compatibility level on Mono and IL2CPP. |
| Defined when Windows Runtime support is enabled on IL2CPP. For more information, refer to WinRT API in C# scripts for UWP. |
| Defined when the Input System package is enabled in Player Settings. |
| Defined when the legacy Input Manager is enabled in Player Settings. |
| Defined when the project is built with Unity Build Automation. |