Skip to content

Commit

Permalink
Guard against missing OpenXR package
Browse files Browse the repository at this point in the history
  • Loading branch information
keveleigh committed Jan 13, 2025
1 parent 8dd224c commit e4c6fd4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
15 changes: 13 additions & 2 deletions org.mixedrealitytoolkit.input/Editor/InputValidation.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
// Copyright (c) Mixed Reality Toolkit Contributors
// Licensed under the BSD 3-Clause

using MixedReality.Toolkit.Editor;
using MixedReality.Toolkit.Subsystems;
using System.Collections.Generic;
using System.Linq;
using Unity.XR.CoreUtils.Editor;
using UnityEditor;
using UnityEngine;

#if UNITY_OPENXR_PRESENT
using MixedReality.Toolkit.Editor;
using UnityEngine.XR.Hands.OpenXR;
using UnityEngine.XR.OpenXR;
#endif

namespace MixedReality.Toolkit.Input.Editor
{
Expand All @@ -25,13 +28,19 @@ private static void AddInputValidationRule()
{
MRTKProjectValidation.AddTargetDependentRules(new List<BuildValidationRule>() { GenerateSpeechInteractorRule(buildTargetGroup) }, buildTargetGroup);

#if UNITY_OPENXR_PRESENT
// Skip the standalone target as the hand subsystem rule for it is already present for all build targets
if (buildTargetGroup != BuildTargetGroup.Standalone)
{
MRTKProjectValidation.AddTargetDependentRules(new List<BuildValidationRule>() { GenerateUnityHandsRule(buildTargetGroup) }, buildTargetGroup);
}
#endif
}
MRTKProjectValidation.AddTargetIndependentRules(new List<BuildValidationRule>() { GenerateSkinWeightsRule(), GenerateGLTFastRule(), GenerateUnityHandsRule(BuildTargetGroup.Standalone) });
MRTKProjectValidation.AddTargetIndependentRules(new List<BuildValidationRule>() { GenerateSkinWeightsRule(), GenerateGLTFastRule(),
#if UNITY_OPENXR_PRESENT
GenerateUnityHandsRule(BuildTargetGroup.Standalone)
#endif
});

// Only generate the KTX rule for platforms related to Meta
MRTKProjectValidation.AddTargetDependentRules(new List<BuildValidationRule>() { GenerateKTXRule() }, BuildTargetGroup.Android);
Expand Down Expand Up @@ -113,6 +122,7 @@ private static BuildValidationRule GenerateKTXRule()
};
}

#if UNITY_OPENXR_PRESENT
private static BuildValidationRule GenerateUnityHandsRule(BuildTargetGroup buildTargetGroup)
{
return new BuildValidationRule()
Expand Down Expand Up @@ -151,5 +161,6 @@ private static BuildValidationRule GenerateUnityHandsRule(BuildTargetGroup build
Error = true
};
}
#endif
}
}
5 changes: 5 additions & 0 deletions org.mixedrealitytoolkit.input/MRTK.Input.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
"expression": "4.2",
"define": "UNITYXR_MANAGEMENT_PRESENT"
},
{
"name": "com.unity.xr.openxr",
"expression": "",
"define": "UNITY_OPENXR_PRESENT"
},
{
"name": "Unity",
"expression": "[2021.3.11,2022.1)",
Expand Down

0 comments on commit e4c6fd4

Please sign in to comment.