Documentation

Unity Engine

Download Unity

Unity Engine

Unity scripting symbol reference

A reference of the predefined scripting symbols Unity provides.
Read time 5 minutesLast updated 8 days ago

Platform symbols

Unity automatically defines certain symbols based on the authoring and build target platform. These are as follows:

Define

Function

UNITY_EDITOR
Scripting symbol to call Unity Editor scripts from your game code.
UNITY_EDITOR_WIN
Scripting symbol for Editor code on Windows.
UNITY_EDITOR_OSX
Scripting symbol for Editor code in macOS.
UNITY_EDITOR_LINUX
Scripting symbol for Editor code on Linux.
UNITY_EMBEDDED_LINUX
Scripting symbol for embedded Linux.
UNITY_QNX
Scripting symbol for QNX.
UNITY_STANDALONE_OSX
Scripting symbol to compile or execute code specifically for macOS (including Universal, PPC and Intel architectures).
UNITY_STANDALONE_WIN
Scripting symbol for compiling/executing code specifically for Windows standalone applications.
UNITY_STANDALONE_LINUX
Scripting symbol for compiling/executing code specifically for Linux standalone applications.
UNITY_STANDALONE
Scripting symbol for compiling/executing code for any standalone platform (Mac OS X, Windows or Linux).
UNITY_SERVER
Scripting symbol for compiling/executing code for a dedicated server (macOS, Windows or Linux).
UNITY_IOS
Scripting symbol for compiling/executing code for the iOS platform.
UNITY_ANDROID
Scripting symbol for the Android platform.
UNITY_TVOS
Scripting symbol for the Apple TV platform.
UNITY_VISIONOS
Scripting symbol for the VisionOS platform.
UNITY_WSA
Scripting symbol for Universal Windows Platform.
UNITY_WSA_10_0
Scripting symbol for Universal Windows Platform.
UNITY_WEBGL
Scripting symbol for Web.
UNITY_ASSERTIONS
Scripting symbol for assertions control process.
UNITY_ASSERTIONS
is always defined for Editor code and defined for builds with Debug and Checked managed code variants.
UNITY_ENABLE_CHECKS
Scripting symbol for enabling safety checks.
UNITY_ENABLE_CHECKS
is always defined for Editor code and defined for builds with Debug and Checked managed code variants.
UNITY_INCLUDE_INSTRUMENTATION
Scripting symbol for enabling instrumentation code paths, such as the profiler.
UNITY_INCLUDE_INSTRUMENTATION
is always defined for Editor code and defined for builds with Debug, Checked, and Instrumented managed code variants.
ENABLE_PROFILER
Scripting symbol for enabling Profiler API calls. Methods such as
Profiler.BeginSample
and
Profiler.EndSample
have the
[Conditional("ENABLE_PROFILER")]
attribute, so Unity removes calls to them when this symbol isn't defined.
ENABLE_PROFILER
is always defined for Editor code and defined for builds with Debug, Checked, and Instrumented managed code variants.
UNITY_INCLUDE_TESTS
Scripting symbol for test code.
UNITY_INCLUDE_TESTS
is always defined for Editor code and defined for builds that include test assemblies. Test assemblies commonly use it as a define constraint so that Unity compiles them only when tests are included.

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
X.Y.Z
(for example, 6000.0.33), Unity exposes three global scripting symbols in the following formats:
UNITY_X
,
UNITY_X_Y
and
UNITY_X_Y_Z
.
Here is an example of scripting symbols exposed in Unity 6000.0.33:

Define

Function

UNITY_6000
Scripting symbol for the release version of Unity 6, exposed in every 6000.Y.Z release.
UNITY_6000_0
Scripting symbol for the major version of Unity 6.0, exposed in every 6000.0.Z release.
UNITY_6000_0_33
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. Following the same version format described previously (
X.Y
), Unity exposes one global
#define
in the format
UNITY_X_Y_OR_NEWER
(for example,
UNITY_6000_0_OR_NEWER
), that you can use for this purpose.

Other symbols

The other symbols Unity defines are:

Define

Function

CSHARP_7_3_OR_NEWER
Defined when building scripts with support for C# 7.3 or newer.
ENABLE_CORECLR
Defined for Editor code and for builds that use the CoreCLR scripting back end.
ENABLE_IL2CPP
Defined for builds that use the IL2CPP scripting back end.
ENABLE_VR
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.
NET_STANDARD_2_0
Defined when building scripts against .NET Standard 2.1 API compatibility level. Unity defines all versioned
NET_STANDARD_X_Y
symbols up to and including the current version.
NET_STANDARD_2_1
Defined when building scripts against .NET Standard 2.1 API compatibility level.
NET_STANDARD
Defined when building scripts against .NET Standard 2.1 API compatibility level.
NETSTANDARD2_1
Defined when building scripts against .NET Standard 2.1 API compatibility level.
NETSTANDARD
Defined when building scripts against .NET Standard 2.1 API compatibility level.
ENABLE_WINMD_SUPPORT
Defined when Windows Runtime support is enabled on IL2CPP. For more information, refer to WinRT API in C# scripts for UWP.
ENABLE_INPUT_SYSTEM
Defined when the Input System package is enabled in Player Settings.
ENABLE_LEGACY_INPUT_MANAGER
Defined when the legacy Input Manager is enabled in Player Settings.
UNITY_CLOUD_BUILD
Defined when the project is built with Unity Build Automation.
Note
The
DEBUG
and
TRACE
symbols are standard C# symbols that enable the methods of the .NET
System.Diagnostics.Debug
and
System.Diagnostics.Trace
classes. Unity defines both symbols for Editor code and for builds that use the Debug managed code variant or have Script Debugging enabled.

Additional resources