Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    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

    mabulous

    Joined:
    Jan 4, 2013
    Posts:
    198
  2. EdBlais

    EdBlais

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    311
    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

    ScottyB

    Joined:
    Apr 4, 2011
    Posts:
    146
    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

    Sysdia

    Joined:
    Apr 6, 2016
    Posts:
    6
    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