Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update MRTK Default Profile to use Unity's XR Hands package #973

Open
wants to merge 7 commits into
base: feature/XRI3
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,16 @@ MonoBehaviour:
m_EditorClassIdentifier:
isCustomProfile: 0
loadedSubsystems:
- reference: MixedReality.Toolkit.Diagnostics.MRTKPerformanceStatsSubsystem,
MixedReality.Toolkit.Diagnostics
- reference: MixedReality.Toolkit.Speech.Windows.WindowsDictationSubsystem,
MixedReality.Toolkit.Speech.Windows
- reference: MixedReality.Toolkit.Input.UnityHandsSubsystem, MixedReality.Toolkit.Input
- reference: MixedReality.Toolkit.Diagnostics.MRTKPerformanceStatsSubsystem, MixedReality.Toolkit.Diagnostics
- reference: MixedReality.Toolkit.Speech.Windows.WindowsDictationSubsystem, MixedReality.Toolkit.Speech.Windows
- reference: MixedReality.Toolkit.Speech.Windows.WindowsKeywordRecognitionSubsystem,
MixedReality.Toolkit.Speech.Windows
- reference: MixedReality.Toolkit.Speech.Windows.WindowsTextToSpeechSubsystem,
MixedReality.Toolkit.Speech.Windows
- reference: MixedReality.Toolkit.Accessibility.MRTKAccessibilitySubsystem,
MixedReality.Toolkit.Accessibility
- reference: MixedReality.Toolkit.Input.OpenXRHandsSubsystem, MixedReality.Toolkit.Input
- reference: MixedReality.Toolkit.Accessibility.MRTKAccessibilitySubsystem, MixedReality.Toolkit.Accessibility
- reference: MixedReality.Toolkit.Input.SyntheticHandsSubsystem, MixedReality.Toolkit.Input
- reference: MixedReality.Toolkit.Input.MRTKHandsAggregatorSubsystem,
MixedReality.Toolkit.Input
- reference: MixedReality.Toolkit.Input.MRTKHandsAggregatorSubsystem, MixedReality.Toolkit.Input
subsystemConfigs:
entries:
- key:
Expand All @@ -47,11 +43,8 @@ MonoBehaviour:
MixedReality.Toolkit.Accessibility
value: {fileID: 11400000, guid: 3aa94a99d7ce5e845a6a78409e004670, type: 2}
- key:
reference: MixedReality.Toolkit.Input.SyntheticHandsSubsystem,
MixedReality.Toolkit.Input
reference: MixedReality.Toolkit.Input.SyntheticHandsSubsystem, MixedReality.Toolkit.Input
value: {fileID: 11400000, guid: c45788af2ca823a4a904bf8762ff126d, type: 2}
- key:
reference: MixedReality.Toolkit.Input.MRTKHandsAggregatorSubsystem,
MixedReality.Toolkit.Input
reference: MixedReality.Toolkit.Input.MRTKHandsAggregatorSubsystem, MixedReality.Toolkit.Input
value: {fileID: 11400000, guid: b8da41358d218754494ea49599e7b0fb, type: 2}
<SpatializationMixer>k__BackingField: {fileID: 3526612193736648505, guid: c4ec596b04ef53f4581688939092e813, type: 2}
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 4e314dfef9af0904e80129bcc0a79361, type: 3}
m_Name: HandTracking WSA
m_EditorClassIdentifier:
m_enabled: 0
m_enabled: 1
nameUi: Hand Tracking Subsystem
version: 0.0.1
featureIdInternal: com.unity.openxr.feature.input.handtracking
Expand Down Expand Up @@ -391,7 +391,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: c79c911b38743a649b1c1eddb5097202, type: 3}
m_Name: HandTrackingFeaturePlugin WSA
m_EditorClassIdentifier:
m_enabled: 1
m_enabled: 0
nameUi: Hand Tracking
version: 1.10.0
featureIdInternal: com.microsoft.openxr.feature.handtracking
Expand Down Expand Up @@ -1062,7 +1062,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: c79c911b38743a649b1c1eddb5097202, type: 3}
m_Name: HandTrackingFeaturePlugin Standalone
m_EditorClassIdentifier:
m_enabled: 1
m_enabled: 0
nameUi: Hand Tracking
version: 1.10.0
featureIdInternal: com.microsoft.openxr.feature.handtracking
Expand Down Expand Up @@ -1128,7 +1128,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: c79c911b38743a649b1c1eddb5097202, type: 3}
m_Name: HandTrackingFeaturePlugin Android
m_EditorClassIdentifier:
m_enabled: 1
m_enabled: 0
nameUi: Hand Tracking
version: 1.10.0
featureIdInternal: com.microsoft.openxr.feature.handtracking
Expand Down
6 changes: 6 additions & 0 deletions org.mixedrealitytoolkit.core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## Unreleased

### Changed

* Updated the MRTK Default Profile to use the Unity XR Hands subsystem by default instead of the Microsoft OpenXR Plugin subsystem. [PR #973](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/pull/973)

## [4.0.0-development.pre.1] - 2024-07-09

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,15 @@ MonoBehaviour:
m_EditorClassIdentifier:
isCustomProfile: 0
loadedSubsystems:
- reference: MixedReality.Toolkit.Speech.Windows.WindowsDictationSubsystem,
MixedReality.Toolkit.Speech.Windows
- reference: MixedReality.Toolkit.Input.UnityHandsSubsystem, MixedReality.Toolkit.Input
- reference: MixedReality.Toolkit.Speech.Windows.WindowsDictationSubsystem, MixedReality.Toolkit.Speech.Windows
- reference: MixedReality.Toolkit.Speech.Windows.WindowsKeywordRecognitionSubsystem,
MixedReality.Toolkit.Speech.Windows
- reference: MixedReality.Toolkit.Speech.Windows.WindowsTextToSpeechSubsystem,
MixedReality.Toolkit.Speech.Windows
- reference: MixedReality.Toolkit.Accessibility.MRTKAccessibilitySubsystem,
MixedReality.Toolkit.Accessibility
- reference: MixedReality.Toolkit.Input.OpenXRHandsSubsystem, MixedReality.Toolkit.Input
- reference: MixedReality.Toolkit.Accessibility.MRTKAccessibilitySubsystem, MixedReality.Toolkit.Accessibility
- reference: MixedReality.Toolkit.Input.SyntheticHandsSubsystem, MixedReality.Toolkit.Input
- reference: MixedReality.Toolkit.Input.MRTKHandsAggregatorSubsystem,
MixedReality.Toolkit.Input
- reference: MixedReality.Toolkit.Input.MRTKHandsAggregatorSubsystem, MixedReality.Toolkit.Input
subsystemConfigs:
entries:
- key:
Expand All @@ -45,11 +42,8 @@ MonoBehaviour:
MixedReality.Toolkit.Accessibility
value: {fileID: 11400000, guid: 3aa94a99d7ce5e845a6a78409e004670, type: 2}
- key:
reference: MixedReality.Toolkit.Input.SyntheticHandsSubsystem,
MixedReality.Toolkit.Input
reference: MixedReality.Toolkit.Input.SyntheticHandsSubsystem, MixedReality.Toolkit.Input
value: {fileID: 11400000, guid: c45788af2ca823a4a904bf8762ff126d, type: 2}
- key:
reference: MixedReality.Toolkit.Input.MRTKHandsAggregatorSubsystem,
MixedReality.Toolkit.Input
reference: MixedReality.Toolkit.Input.MRTKHandsAggregatorSubsystem, MixedReality.Toolkit.Input
value: {fileID: 11400000, guid: b8da41358d218754494ea49599e7b0fb, type: 2}
<SpatializationMixer>k__BackingField: {fileID: 0}
14 changes: 3 additions & 11 deletions org.mixedrealitytoolkit.core/Editor/MRTKProjectValidation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
// Licensed under the BSD 3-Clause

using MixedReality.Toolkit.Editor;
using System;
using System.Collections.Generic;
using System.Linq;
using Unity.XR.CoreUtils.Editor;
using UnityEditor;
using UnityEngine;
Expand All @@ -16,12 +14,6 @@ namespace MixedReality.Toolkit
/// </summary>
public static class MRTKProjectValidation
{
#pragma warning disable 618
private static readonly BuildTargetGroup[] excludedBuildTargetGroups = new BuildTargetGroup[]
// Need to cast int back to BuildTargetGroup because BuildTargetGroup.WebPlayer is marked as obsolete and treated as an error
{ (BuildTargetGroup)2, BuildTargetGroup.PS3, BuildTargetGroup.XBOX360, BuildTargetGroup.WP8, BuildTargetGroup.BlackBerry, BuildTargetGroup.Tizen, BuildTargetGroup.PSP2,
BuildTargetGroup.PSM, BuildTargetGroup.SamsungTV, BuildTargetGroup.N3DS, BuildTargetGroup.WiiU, BuildTargetGroup.Facebook, BuildTargetGroup.Switch };
#pragma warning restore 618
private const string XRProjectValidationSettingsPath = "Project/XR Plug-in Management/Project Validation";
private const string DefaultMRTKProfileGuid = "c677e5c4eb85b7849a8da406775c299d";
private static readonly Dictionary<BuildTargetGroup, List<BuildValidationRule>> validationRulesDictionary = new Dictionary<BuildTargetGroup, List<BuildValidationRule>>();
Expand All @@ -32,7 +24,7 @@ public static class MRTKProjectValidation
/// <remarks>
/// Build targets currently not supported by MRTK will be filtered out.
/// </remarks>
public static readonly BuildTargetGroup[] BuildTargetGroups = ((BuildTargetGroup[])Enum.GetValues(typeof(BuildTargetGroup))).Distinct().Except(excludedBuildTargetGroups).ToArray();
public static readonly BuildTargetGroup[] BuildTargetGroups = { BuildTargetGroup.Standalone, BuildTargetGroup.Android, BuildTargetGroup.WSA };

[MenuItem("Mixed Reality/MRTK3/Utilities/Project Validation", priority = 0)]
private static void MenuItem()
Expand All @@ -50,7 +42,7 @@ private static void MRTKProjectValidationCheck()

private static void AddMRTKValidationRules()
{
foreach (var buildTargetGroup in validationRulesDictionary.Keys)
foreach (BuildTargetGroup buildTargetGroup in validationRulesDictionary.Keys)
{
BuildValidator.AddRules(buildTargetGroup, validationRulesDictionary[buildTargetGroup]);
}
Expand All @@ -70,7 +62,7 @@ private static void AddMRTKCoreValidationRules()
AddTargetIndependentRules(mrtkCoreTargetIndependentRules);

// Add target-specific rules
foreach (var buildTargetGroup in BuildTargetGroups)
foreach (BuildTargetGroup buildTargetGroup in BuildTargetGroups)
{
// Skip the standalone target as the profile rule for it is already present for all build targets
if (buildTargetGroup != BuildTargetGroup.Standalone)
Expand Down
4 changes: 4 additions & 0 deletions org.mixedrealitytoolkit.input/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## Unreleased

### Added

* Added a project validation rule to ensure the Unity XR Hands subsystem is enabled in the OpenXR settings when the corresponding MRTK subsystem is enabled. [PR #973](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/pull/973)

## [4.0.0-development.pre.1] - 2024-07-16

### Added
Expand Down
63 changes: 61 additions & 2 deletions org.mixedrealitytoolkit.input/Editor/InputValidation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@
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
{
/// <summary>
/// A class adding input related rule(s) to the validator
/// A class adding input related rule(s) to the validator.
/// </summary>
internal static class InputValidation
{
Expand All @@ -21,8 +27,20 @@ private static void AddInputValidationRule()
foreach (var buildTargetGroup in MRTKProjectValidation.BuildTargetGroups)
{
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() });
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 @@ -103,5 +121,46 @@ private static BuildValidationRule GenerateKTXRule()
Error = false
};
}

#if UNITY_OPENXR_PRESENT
private static BuildValidationRule GenerateUnityHandsRule(BuildTargetGroup buildTargetGroup)
{
return new BuildValidationRule()
{
IsRuleEnabled = () => MRTKSettings.ProfileForBuildTarget(buildTargetGroup).LoadedSubsystems.Contains(typeof(UnityHandsSubsystem)),
Category = "MRTK3",
Message = $"When {nameof(UnityHandsSubsystem)} is enabled for the {buildTargetGroup} build target, " +
$"{nameof(HandTracking)} must also be enabled in the OpenXR settings for {buildTargetGroup}.",
CheckPredicate = () =>
{
OpenXRSettings settings = OpenXRSettings.GetSettingsForBuildTargetGroup(buildTargetGroup);
if (settings == null)
{
return false;
}

HandTracking handFeature = settings.GetFeature<HandTracking>();
return handFeature != null && handFeature.enabled;
},
FixIt = () =>
{
OpenXRSettings settings = OpenXRSettings.GetSettingsForBuildTargetGroup(buildTargetGroup);
if (settings == null)
{
return;
}

HandTracking handFeature = settings.GetFeature<HandTracking>();
if (handFeature != null)
{
handFeature.enabled = true;
EditorUtility.SetDirty(settings);
}
},
FixItMessage = $"Enable {nameof(HandTracking)} in the OpenXR settings.",
Error = true
};
}
#endif
}
}
11 changes: 9 additions & 2 deletions org.mixedrealitytoolkit.input/Editor/MRTK.Input.Editor.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
"references": [
"MixedReality.Toolkit.Core",
"MixedReality.Toolkit.Core.Editor",
"MixedReality.Toolkit.Input",
"MixedReality.Toolkit.Input",
"Unity.XR.CoreUtils",
"Unity.XR.CoreUtils.Editor",
"Unity.XR.Hands",
"Unity.XR.Interaction.Toolkit",
"Unity.XR.Interaction.Toolkit.Editor",
"Unity.XR.Management"
"Unity.XR.Management",
"Unity.XR.OpenXR"
],
"includePlatforms": [
"Editor"
Expand All @@ -35,6 +37,11 @@
"name": "com.unity.xr.management",
"expression": "4.2",
"define": "UNITYXR_MANAGEMENT_PRESENT"
},
{
"name": "com.unity.xr.openxr",
"expression": "",
"define": "UNITY_OPENXR_PRESENT"
}
],
"noEngineReferences": false
Expand Down