Search Unity

Creating Preprocessor Directives for SteamVR and OculusVR

Discussion in 'AR/VR (XR) Discussion' started by NateCasillas, Jan 10, 2019.

  1. NateCasillas

    NateCasillas

    Joined:
    Oct 30, 2018
    Posts:
    2
    I'm attempting to take a VR project that was written to run with SteamVR to be compatible with OculusVR as well. From what I've read I need to use #define directives, but I'm lost on how exactly to go about doing this. How do I create a #define OCULUS, for example, that will only be defined when I'm using the OculusVR sdk? Or is there a way to create a directive that is defined in an exclusive scene??
     
  2. NateCasillas

    NateCasillas

    Joined:
    Oct 30, 2018
    Posts:
    2
    I've solved this.
    I added a define directive for Oculus with the following:
    if(XRSettings.loadedDeviceName == "Oculus")
    PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone, "OCULUS");
     
    castana1962 likes this.