Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Our response to Improbable’s blog post (and why you can keep working on your SpatialOS game). Read more here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Creating Preprocessor Directives for SteamVR and OculusVR

Discussion in 'AR/VR (XR) Discussion' started by NateCasillas, Jan 10, 2019 at 12:33 AM.

  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.