Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Runtime/Association/LoadedXrDeviceAssociation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
using System;
using System.Text.RegularExpressions;
using UnityEngine;
#if UNITY_XR || UNITY_VR
using UnityEngine.XR;
#endif

/// <summary>
/// Holds <see cref="GameObject"/>s to (de)activate based on the loaded XR device's name.
Expand All @@ -23,7 +25,11 @@ public class LoadedXrDeviceAssociation : GameObjectsAssociation
/// <inheritdoc/>
public override bool ShouldBeActive()
{
#if UNITY_VR
return Regex.IsMatch(XRSettings.loadedDeviceName, XrDeviceNamePattern);
#else
return false;
#endif
}
}
}
8 changes: 8 additions & 0 deletions Runtime/Association/PlatformDeviceAssociation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
using Malimbe.XmlDocumentationAttribute;
using System.Text.RegularExpressions;
using UnityEngine;
#if UNITY_XR || UNITY_VR
using UnityEngine.XR;
#endif

/// <summary>
/// Holds <see cref="GameObject"/>s to (de)activate based on the current platform and loaded XR device type.
Expand Down Expand Up @@ -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);

}
Expand Down
6 changes: 4 additions & 2 deletions Runtime/Haptics/XRNodeHapticPulser.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace Zinnia.Haptics
#if UNITY_XR
namespace Zinnia.Haptics
{
using Malimbe.PropertySerializationAttribute;
using Malimbe.XmlDocumentationAttribute;
Expand Down Expand Up @@ -83,4 +84,5 @@ protected virtual byte[] GeneratePulseBuffer(float intensity, float duration)
return clip;
}
}
}
}
#endif
6 changes: 4 additions & 2 deletions Runtime/Tracking/Velocity/XRNodeVelocityEstimator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace Zinnia.Tracking.Velocity
#if UNITY_XR
namespace Zinnia.Tracking.Velocity
{
using Malimbe.MemberClearanceMethod;
using Malimbe.PropertySerializationAttribute;
Expand Down Expand Up @@ -66,4 +67,5 @@ protected virtual XRNodeState GetNodeState()
return new XRNodeState();
}
}
}
}
#endif
15 changes: 14 additions & 1 deletion Runtime/Zinnia.Runtime.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -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
}