UnityEngine.VR is being renamed to UnityEngine.XR in 2017.2 (2017.2 VR to XR rename (scripts) - Unity Engine - Unity Discussions)
How would one write a managed plugin (compiled dll) that supports pre 2017.2 as well as post 2017.2 versions of Unity?
UnityEngine.VR is being renamed to UnityEngine.XR in 2017.2 (2017.2 VR to XR rename (scripts) - Unity Engine - Unity Discussions)
How would one write a managed plugin (compiled dll) that supports pre 2017.2 as well as post 2017.2 versions of Unity?
Something that is a little less known is that the Unity Script updater also runs for managed assemblies/plugins/dlls. So all you should need to do it target the lowest Unity version that you wish your plugin to support. Then, if you drop the plugin in a newer version of Unity with the UnityEngine.XR change, the script updater should scan your plugin and update any references automatically.
If you run into any issues with this (as in the script updater not updating properly), just @ me on this thread.
The other option is to use code like this:
#if UNITY_2017_2_OR_NEWER
using UnityEngine.XR;
#else
using UnityEngine.VR;
#endif
This isn’t going to work because the classes have also been renamed, not just the packages.
E.g. VRSettings.supportedDevices becomes XRSettings.supportedDevices
so you will have to alias them like:
using XRSettings = UnityEngine.VR.VRSettings
Then anywhere in your code if you refer to VRSettings you can now simply refer to XRSettings and this is just an alias to VRSettings still.
Another further note: Some of the methods have also been renamed (annoyingly without deprecation!)
So for instance VRSettings.renderScale has now become XRSettings.eyeTextureResolutionScale
In these cases you’ll have to provide a helper method that wraps the different versions and return the float result. Then you can just reference your own helper method.