i just tried to add support for Unity 2018.2 to some shaders – but had to face the fact that: #if UNITY_VERSION > 20180202
or #if UNITY_VERSION > 201822
did not work out at all.
so is it broken or do i do something completely wrong here?
#if UNITY_VERSION > 201822
This should work. This will include the code inside the ‘#if’ part for Unity versions higher than 2018.2.2
What you probably want is ‘#if UNITY_VERSION >= 201820’. This will include the code for any Unity version starting from 2018.2.0
thanks for the tip, but unfortunately it does not work…
i tried: #if UNITY_VERSION >= 201820 #pragma multi_compile_vertex LOD_FADE_PERCENTAGE #else #pragma multi_compile LOD_FADE_CROSSFADE LOD_FADE_PERCENTAGE #endif
but the compiler complains about “redefinition of _MainTex”
only if i use: #pragma multi_compile_vertex LOD_FADE_PERCENTAGE
and skip the #if#else and 2nd #pragma the shader compiles properly.
afaik, it’s not possible
what you could try to do is take a look, which include file is included first, make your own .cginc with the same name, put the #if there and include the global one afterwards
A bit of a necro, but it appears UNITY_VERSION really is legitimately broken for editor versions which reach double digit revision numbers.
For example: 2018.2.20
Going by the documentation, or this thread, one might expect the UNITY_VERSION to be 2018220, but that messes with the original numbering system as now the 6 digit long version for 2019.1.0 (201910) would be less than the 7 digits of the expected version number. The actual UNITY_VERSION for 2018.2.20 is:
2018**40**
It appears to be combining the “.2.20” in to 40 which kind of makes sense if you think about the easiest way to convert the Unity version into a single number.
Of course collides with what you expect 2018.4.0 to be, which is 201840. It also collides with 2018.3.10 which also uses 201840! 2018.3.11 through 2018.3.14 all use 201839, so someone noticed the problem. Just be warned the number system is inconsistent now.
Hmm. As far as I remember, the fix to clamp versions to max of 9 should have landed to 2017.4 LTS, 2018.3 & 2018.4 LTS, and is in all 2019.x versions. So yeah 2018.2 is probably missing it… is that a big problem?