Version: Unity 6.0 (6000.0)
Language : English
Branch in a shader via built-in macros
Branch based on shader model

Platform and graphics API macros

Macro: Target platform:
SHADER_API_D3D11 Direct3D 11
SHADER_API_GLCORE Desktop OpenGL “core” (GL 3/4)
SHADER_API_GLES3 OpenGL ES 3.0/3.1
SHADER_API_METAL iOS/Mac Metal
SHADER_API_VULKAN Vulkan
SHADER_API_D3D11_9X Direct3D 11 “feature level 9.x” target for Universal Windows Platform
SHADER_API_DESKTOP Windows, Mac and Linux desktop platforms, Web
SHADER_API_MOBILE iOS and Android mobile platforms, tvOS

Additionally, SHADER_TARGET_GLSL is defined when the target shading language is GLSL (always true for OpenGL/GLES platforms).

Platform build macros

The following macros are available only when you make the corresponding platform the target for your build.

Macro Platform
UNITY_PLATFORM_ANDROID Android devices
UNITY_PLATFORM_EMBEDDED_LINUX Embedded Linux devices
UNITY_PLATFORM_GAMECORE_XBOXONE Xbox One Game Core
UNITY_PLATFORM_IOS iOS devices
UNITY_PLATFORM_LINUX Linux devices
UNITY_PLATFORM_OSX macOS devices
UNITY_PLATFORM_PS4 PlayStation®4
UNITY_PLATFORM_PS5 PlayStation®5
UNITY_PLATFORM_QNX QNX devices
UNITY_PLATFORM_SWITCH Nintendo Switch™
UNITY_PLATFORM_SWITCH2 Nintendo Switch™ 2
UNITY_PLATFORM_TVOS tvOS devices
UNITY_PLATFORM_UWP Universal Windows Platform (UWP) devices
UNITY_PLATFORM_VISIONOS visionOS devices
UNITY_PLATFORM_WEBGL WebGLA JavaScript API that renders 2D and 3D graphics in a web browser. The Unity Web build option allows Unity to publish content as JavaScript programs which use HTML5 technologies and the WebGL rendering API to run Unity content in a web browser. More info
See in Glossary
devices
UNITY_PLATFORM_WINDOWS Windows devices
UNITY_PLATFORM_XBOXONE Xbox One

Additional resources

Branch in a shader via built-in macros
Branch based on shader model