Unity 2017 is not considered newer than Unity 5.3.4 in Platform dependent compilation

In the 2017 docs it still says:

“Starting from Unity 5.3.4, you can compile code selectively based on the earliest version of Unity required to compile or execute a given portion of code. Given the same version format as above (X.Y.Z), Unity exposes one global #define in the format UNITY_X_Y_OR_NEWER, that can be used for this purpose.”

However scripts that use the definition “#if UNITY_5_3_4_OR_NEWER” don’t work in Unity 2017- Unity2017 is obviously not considered ‘newer’. Instead you have to modify your code (resubmit to the app store etc) to use the new ‘#if UNITY_2017_1_OR_NEWER’ in addition.

Is this a bug or a ‘feature’?

3 Likes

Sounds like a bug. Throw in a report.

I can think of no reason why this might have been deliberately included.

The docs are unclear, it actually means UNITY_5_3_OR_NEWER is the first version that will work. That’s what they mean with “Starting in Unity 5.3.4”.

The docs mention X Y (5 3), yet you are trying to use X Y Z (5 3 4).
If you try with UNITY_5_3_OR_NEWER instead of UNITY_5_3_4_OR_NEWER, does it work?

UNITY_5_3_OR_NEWER work fine.

How to distinguish the different version between 2018.1 and 2019.1?
I try to like this: UNITY_2019_1_1_OR_NEWER, but it’s not ok.

The docs says that UNITY_X_Y_OR_NEWER is supported, so that means that you want UNITY_2019_1_OR_NEWER