Branch based on Unity version
Use UNITY_VERSION to make shader behaviour conditional on the Unity version.
読み終わるまでの所要時間 1 分最終更新 25日前
UNITY_VERSIONThis can be used for version comparisons if you need to write shaders that use different built-in shader functionality. For example, use if you want the preprocessor check to pass only on Unity version 6.0 or later.
#if UNITY_VERSION >= 60000000Unity 6
Use the format , where:
6MMMPPPP- is Unity 6.
6 - is the minor version with leading zeroes, for example
MMMfor Unity 6.2.002 - is the patch version with leading zeroes, for example
PPPPfor Unity 6.2.1234.1234
For example, for Unity 6000.2.3, use .
60020003Unity 2023 or earlier
Use the format , where:
YYYYMP- is the major version.
YYYY - is the minor version.
M - is the patch version.
P
For example, for Unity 2022.3.0, use .
202230You can use only values up to 9 for the minor and patch versions. This means you can't check for a Unity version with a minor version larger than 9 or a patch version larger than 9.