Skip to content

Commit 5bbb3b7

Browse files
authored
Merge branch 'feature/XRI3' into update-to-2022
2 parents 350b7b0 + 7d08495 commit 5bbb3b7

7 files changed

Lines changed: 121 additions & 9 deletions

File tree

UnityProjects/MRTKDevTemplate/Assets/BuildAssets/BuildApp.cs

Lines changed: 108 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
// Copyright (c) Mixed Reality Toolkit Contributors
22
// Licensed under the BSD 3-Clause
33

4-
// Disable "missing XML comment" warning for samples. While nice to have, this XML documentation is not required for samples.
5-
#pragma warning disable CS1591
6-
4+
using MixedReality.Toolkit.Input;
75
using System;
86
using System.IO;
97
using System.Linq;
@@ -18,7 +16,7 @@ namespace MixedReality.Toolkit.Examples.Build
1816
/// </summary>
1917
public static class BuildApp
2018
{
21-
private static string[] scenes =
19+
private static string[] scenes =
2220
{
2321
"Assets/Scenes/BoundsControlExamples.unity",
2422
"Assets/Scenes/CanvasExample.unity",
@@ -151,6 +149,10 @@ private static void ParseBuildCommandLine()
151149
case "-buildOutput":
152150
buildPath = arguments[++i];
153151
break;
152+
case "-debug":
153+
// Add hand joints to hand visualization for debugging purposes
154+
PatchDebugHands();
155+
break;
154156
}
155157
}
156158
}
@@ -160,6 +162,107 @@ private static string[] SplitSceneList(string sceneList)
160162
return (from scene in sceneList.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
161163
select scene.Trim()).ToArray();
162164
}
165+
166+
#region Hand Debug Patching
167+
168+
private const string LeftHandVisualizerGuid = "2b468cc4fe6d2b44ebc53b958b38b91a";
169+
private const string RightHandVisualizerGuid = "da93d751ddc0f64468dfc02f18d02d00";
170+
private const string HandJointMaterialGuid = "f115122e8379c044faecfec013fda057";
171+
172+
[MenuItem("Mixed Reality/MRTK3/Examples/Patch debug hand visualization...")]
173+
private static void PatchDebugHands() => PatchHands(true);
174+
175+
[MenuItem("Mixed Reality/MRTK3/Examples/Patch debug hand visualization...", true)]
176+
private static bool ValidatePatchDebugHands() => !AreHandsPatched();
177+
178+
[MenuItem("Mixed Reality/MRTK3/Examples/Unpatch debug hand visualization...")]
179+
private static void UnpatchDebugHands() => PatchHands(false);
180+
181+
[MenuItem("Mixed Reality/MRTK3/Examples/Unpatch debug hand visualization...", true)]
182+
private static bool ValidateUnpatchDebugHands() => AreHandsPatched();
183+
184+
/// <summary>
185+
/// Checks both hand prefabs for a <see cref="HandJointVisualizer"/>.
186+
/// </summary>
187+
/// <returns>Whether the left and right hands both have <see cref="HandJointVisualizer"/> scripts.</returns>
188+
private static bool AreHandsPatched()
189+
{
190+
bool isPatched = true;
191+
192+
string rightHandPath = AssetDatabase.GUIDToAssetPath(RightHandVisualizerGuid);
193+
{
194+
GameObject rightHandVisualizer = PrefabUtility.LoadPrefabContents(rightHandPath);
195+
if (rightHandVisualizer != null)
196+
{
197+
isPatched &= rightHandVisualizer.TryGetComponent<HandJointVisualizer>(out _);
198+
}
199+
PrefabUtility.UnloadPrefabContents(rightHandVisualizer);
200+
}
201+
202+
string leftHandPath = AssetDatabase.GUIDToAssetPath(LeftHandVisualizerGuid);
203+
{
204+
GameObject leftHandVisualizer = PrefabUtility.LoadPrefabContents(leftHandPath);
205+
if (leftHandVisualizer != null)
206+
{
207+
isPatched &= leftHandVisualizer.TryGetComponent<HandJointVisualizer>(out _);
208+
}
209+
PrefabUtility.UnloadPrefabContents(leftHandVisualizer);
210+
}
211+
212+
return isPatched;
213+
}
214+
215+
/// <summary>
216+
/// Updates both the left and right hand prefabs with <see cref="HandJointVisualizer"/> scripts.
217+
/// </summary>
218+
/// <param name="addDebug">If <see langword="true"/>, <see cref="HandJointVisualizer"/> will be added. If <see langword="false"/>, it'll be removed.</param>
219+
private static void PatchHands(bool addDebug)
220+
{
221+
string rightHandPath = AssetDatabase.GUIDToAssetPath(RightHandVisualizerGuid);
222+
{
223+
GameObject rightHandVisualizer = PrefabUtility.LoadPrefabContents(rightHandPath);
224+
if (rightHandVisualizer != null)
225+
{
226+
if (addDebug)
227+
{
228+
HandJointVisualizer visualizer = rightHandVisualizer.EnsureComponent<HandJointVisualizer>();
229+
visualizer.HandNode = UnityEngine.XR.XRNode.RightHand;
230+
visualizer.JointMaterial = AssetDatabase.LoadAssetAtPath<Material>(AssetDatabase.GUIDToAssetPath(HandJointMaterialGuid));
231+
visualizer.JointMesh = Resources.GetBuiltinResource<Mesh>("Cube.fbx");
232+
}
233+
else if (rightHandVisualizer.TryGetComponent(out HandJointVisualizer handJointVisualizer))
234+
{
235+
UnityEngine.Object.DestroyImmediate(handJointVisualizer);
236+
}
237+
PrefabUtility.SaveAsPrefabAsset(rightHandVisualizer, rightHandPath);
238+
}
239+
PrefabUtility.UnloadPrefabContents(rightHandVisualizer);
240+
}
241+
242+
string leftHandPath = AssetDatabase.GUIDToAssetPath(LeftHandVisualizerGuid);
243+
{
244+
GameObject leftHandVisualizer = PrefabUtility.LoadPrefabContents(leftHandPath);
245+
if (leftHandVisualizer != null)
246+
{
247+
if (addDebug)
248+
{
249+
HandJointVisualizer visualizer = leftHandVisualizer.EnsureComponent<HandJointVisualizer>();
250+
visualizer.HandNode = UnityEngine.XR.XRNode.LeftHand;
251+
visualizer.JointMaterial = AssetDatabase.LoadAssetAtPath<Material>(AssetDatabase.GUIDToAssetPath(HandJointMaterialGuid));
252+
visualizer.JointMesh = Resources.GetBuiltinResource<Mesh>("Cube.fbx");
253+
}
254+
#if UNITY_6000_0_OR_NEWER
255+
else
256+
{
257+
PrefabUtility.RemoveUnusedOverrides(new[] { leftHandVisualizer }, UnityEditor.InteractionMode.UserAction);
258+
}
259+
#endif
260+
PrefabUtility.SaveAsPrefabAsset(leftHandVisualizer, leftHandPath);
261+
}
262+
PrefabUtility.UnloadPrefabContents(leftHandVisualizer);
263+
}
264+
}
265+
266+
#endregion Hand Debug Patching
163267
}
164268
}
165-
#pragma warning restore CS1591

UnityProjects/MRTKDevTemplate/Assets/BuildAssets/MRTK.Examples.Build.asmdef

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
"name": "MixedReality.Toolkit.Examples.Build",
33
"rootNamespace": "",
44
"references": [
5+
"GUID:56255bd5d851a6243b63cb370cfc40b1",
6+
"GUID:d59347cf3d47ac148925927618efb1b5",
7+
"GUID:fe685ec1767f73d42b749ea8045bfe43",
58
"GUID:f9fe0089ec81f4079af78eb2287a6163",
69
"GUID:4847341ff46394e83bb78fbd0652937e"
710
],
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"<Ruleset>k__BackingField": 0
3+
}

UnityProjects/MRTKDevTemplate/ProjectSettings/ProjectSettings.asset

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ PlayerSettings:
7676
androidFullscreenMode: 1
7777
defaultIsNativeResolution: 1
7878
macRetinaSupport: 1
79-
runInBackground: 1
79+
runInBackground: 0
8080
captureSingleScreen: 0
8181
muteOtherAudioSources: 0
8282
Prepare IOS For Recording: 0

org.mixedrealitytoolkit.core/CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
3232

3333
* ControllerLookup marked as Obsolete.
3434

35-
## [3.2.3-development] - 2024-06-24
35+
## Unreleased 3.x
3636

3737
### Fixed
3838

3939
* Fixed broken project validation help link, for item 'MRTK3 profile may need to be assigned for the Standalone build target' (Issue #882) [PR #886](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/pull/886)
4040
* Fixed the "Is Interactable" convenience alias on StatefulInteractableEditor to allow multi-object editing in the Inspector to update all values. (Issue #573) [PR #943](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/pull/943)
41+
* Augment SerializableDictionary to allow temporary duplicates in Editor to prevent serialization errors. [PR #961](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/pull/961)
42+
* Fix an issue with the "Init Controllers" type lookup within InteractionModeManager.InitializeControllers() to find XRBaseControllers instead of XRControllers. [PR #961](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/pull/961)
4143

42-
## [3.2.2-development] - 2024-06-13
44+
## [3.2.2] - 2024-09-18
4345

4446
### Fixed
4547

org.mixedrealitytoolkit.core/Utilities/Extensions/ComponentExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,4 @@ public static Component EnsureComponent(this GameObject gameObject, Type compone
6565
return gameObject.TryGetComponent(component, out Component foundComponent) ? foundComponent : gameObject.AddComponent(component);
6666
}
6767
}
68-
}
68+
}

org.mixedrealitytoolkit.uxcore/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
1414
* Fixed an issue when selecting a PressableButton in Editor scene view causing error spam. (Issue #772) [PR #943](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/pull/943)
1515
* Prevent simultaneous editing of multiple input fields when using Non-Native Keyboard. [PR #942](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/pull/942)
1616
* Don't try to start a coroutine in VirtualizedScrollRectList when the GameObject is inactive. [PR #972](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/pull/972)
17+
* Fix SliderSounds playing sound even when disabled. [PR #1007](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/pull/1007)
1718

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

0 commit comments

Comments
 (0)