Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

support UnityEngine.VR as well as UnityEngine.XR in compiled dll

Discussion in '2017.2 Beta' started by mabulous, Aug 25, 2017.

  1. mabulous


    Jan 4, 2013
  2. EdBlais


    Unity Technologies

    Nov 18, 2013
    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.
  3. ScottyB


    Apr 4, 2011
    The other option is to use code like this:
    Code (CSharp):
    1. #if UNITY_2017_2_OR_NEWER
    2. using UnityEngine.XR;
    3. #else
    4. using UnityEngine.VR;
    5. #endif
  4. Sysdia


    Apr 6, 2016
    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.
    Last edited: Sep 6, 2017