diff --git a/Runtime/Association/LoadedXrDeviceAssociation.cs b/Runtime/Association/LoadedXrDeviceAssociation.cs index 4bdb68c1..e80f79da 100644 --- a/Runtime/Association/LoadedXrDeviceAssociation.cs +++ b/Runtime/Association/LoadedXrDeviceAssociation.cs @@ -5,7 +5,9 @@ using System; using System.Text.RegularExpressions; using UnityEngine; +#if UNITY_XR || UNITY_VR using UnityEngine.XR; +#endif /// /// Holds s to (de)activate based on the loaded XR device's name. @@ -23,7 +25,11 @@ public class LoadedXrDeviceAssociation : GameObjectsAssociation /// public override bool ShouldBeActive() { +#if UNITY_VR return Regex.IsMatch(XRSettings.loadedDeviceName, XrDeviceNamePattern); +#else + return false; +#endif } } } \ No newline at end of file diff --git a/Runtime/Association/PlatformDeviceAssociation.cs b/Runtime/Association/PlatformDeviceAssociation.cs index 1cdbcb03..700c1099 100644 --- a/Runtime/Association/PlatformDeviceAssociation.cs +++ b/Runtime/Association/PlatformDeviceAssociation.cs @@ -4,7 +4,9 @@ using Malimbe.XmlDocumentationAttribute; using System.Text.RegularExpressions; using UnityEngine; +#if UNITY_XR || UNITY_VR using UnityEngine.XR; +#endif /// /// Holds s to (de)activate based on the current platform and loaded XR device type. @@ -36,13 +38,19 @@ public override bool ShouldBeActive() { string modelName = ""; #if UNITY_2020_2_OR_NEWER +#if UNITY_XR InputDevice currentDevice = InputDevices.GetDeviceAtXRNode(XRNode.Head); modelName = currentDevice != null && currentDevice.name != null ? currentDevice.name : ""; +#endif #else +#if UNITY_VR modelName = XRDevice.model; +#endif #endif return Regex.IsMatch(Application.platform.ToString(), PlatformPattern) && +#if UNITY_VR Regex.IsMatch(XRSettings.loadedDeviceName, XrSdkPattern) && +#endif Regex.IsMatch(modelName, XrModelPattern); } diff --git a/Runtime/Haptics/XRNodeHapticPulser.cs b/Runtime/Haptics/XRNodeHapticPulser.cs index 3266ace3..dfe5f46e 100644 --- a/Runtime/Haptics/XRNodeHapticPulser.cs +++ b/Runtime/Haptics/XRNodeHapticPulser.cs @@ -1,4 +1,5 @@ -namespace Zinnia.Haptics +#if UNITY_XR +namespace Zinnia.Haptics { using Malimbe.PropertySerializationAttribute; using Malimbe.XmlDocumentationAttribute; @@ -83,4 +84,5 @@ protected virtual byte[] GeneratePulseBuffer(float intensity, float duration) return clip; } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/Runtime/Tracking/Velocity/XRNodeVelocityEstimator.cs b/Runtime/Tracking/Velocity/XRNodeVelocityEstimator.cs index 747df74f..899283a2 100644 --- a/Runtime/Tracking/Velocity/XRNodeVelocityEstimator.cs +++ b/Runtime/Tracking/Velocity/XRNodeVelocityEstimator.cs @@ -1,4 +1,5 @@ -namespace Zinnia.Tracking.Velocity +#if UNITY_XR +namespace Zinnia.Tracking.Velocity { using Malimbe.MemberClearanceMethod; using Malimbe.PropertySerializationAttribute; @@ -66,4 +67,5 @@ protected virtual XRNodeState GetNodeState() return new XRNodeState(); } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/Runtime/Zinnia.Runtime.asmdef b/Runtime/Zinnia.Runtime.asmdef index 91aef1af..a366fb84 100644 --- a/Runtime/Zinnia.Runtime.asmdef +++ b/Runtime/Zinnia.Runtime.asmdef @@ -14,5 +14,18 @@ "Malimbe.XmlDocumentationAttribute.dll" ], "autoReferenced": true, - "defineConstraints": [] + "defineConstraints": [], + "versionDefines": [ + { + "name": "com.unity.modules.xr", + "expression": "", + "define": "UNITY_XR" + }, + { + "name": "com.unity.modules.vr", + "expression": "", + "define": "UNITY_VR" + } + ], + "noEngineReferences": false } \ No newline at end of file