Skip to content

Commit 1b157fb

Browse files
Adding the scene reorientation functionality (#10100)
* Adding ReorientContent() to MixedRealitySceneContent.cs Updating ToggleFeaturesPanel for Examples Hub to include reorient functionality. * Scene Content Height Fix * added align with head pose option to mrtk scene content, adjusted some scenes * Updating example scenes to have proper MixedRealitySceneContent object with (0,0,0) position and set Alignment Type 'Align with head pose' * Hub menu fix * fixing mistaken checked in files * remaining changes * whitespace * reverting unintended scene changes * whitespace fix * Update SurfaceMagnetismSpatialAwarenessExample.unity * updating profile * scene transition service now runs on quest/android * enabled teleport system * fixing CI complaints Co-authored-by: RogPodge <[email protected]> Co-authored-by: Yoon Park <[email protected]> Co-authored-by: RogPodge <[email protected]>
1 parent f82aa59 commit 1b157fb

25 files changed

+44742
-55374
lines changed

Assets/MRTK/Core/Utilities/SceneContent/MixedRealitySceneContent.cs

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ public class MixedRealitySceneContent : MonoBehaviour
2121
private enum AlignmentType
2222
{
2323
AlignWithExperienceScale,
24-
AlignWithHeadHeight
24+
AlignWithHeadHeight,
25+
AlignWithHeadPose
2526
}
2627

2728
[SerializeField]
@@ -33,6 +34,7 @@ private enum AlignmentType
3334
private Transform containerObject = null;
3435

3536
private Vector3 contentPosition = Vector3.zero;
37+
private Quaternion contentOrientation = Quaternion.identity;
3638
private const uint MaxEditorFrameWaitCount = 15;
3739
private Coroutine initializeSceneContentWithDelay;
3840

@@ -95,9 +97,10 @@ public void InitializeSceneContent()
9597

9698
MixedRealityExperienceSettingsProfile experienceSettingsProfile = MixedRealityToolkit.Instance.ActiveProfile.ExperienceSettingsProfile;
9799

98-
if (alignmentType == AlignmentType.AlignWithExperienceScale)
100+
switch (alignmentType)
99101
{
100-
bool experienceAdjustedByXRDevice =
102+
case AlignmentType.AlignWithExperienceScale:
103+
bool experienceAdjustedByXRDevice =
101104
#if UNITY_2020_1_OR_NEWER
102105
XRSubsystemHelpers.InputSubsystem != null && XRSubsystemHelpers.InputSubsystem.GetTrackingOriginMode().HasFlag(TrackingOriginModeFlags.Floor);
103106
#elif UNITY_2019_1_OR_NEWER
@@ -109,30 +112,48 @@ public void InitializeSceneContent()
109112
XRDevice.isPresent && XRDevice.GetTrackingSpaceType() == TrackingSpaceType.RoomScale;
110113
#endif // UNITY_2020_1_OR_NEWER
111114

112-
// The scene content will be adjusted upwards if the target experience scale is set to room or world scale
113-
// AND if we are either in editor (!XRDevicePresent) or we are on an XR device that will adjust the camera's height
114-
if ((experienceSettingsProfile.TargetExperienceScale == ExperienceScale.Room ||
115-
experienceSettingsProfile.TargetExperienceScale == ExperienceScale.World) &&
116-
(!DeviceUtility.IsPresent || experienceAdjustedByXRDevice))
117-
{
115+
// The scene content will be adjusted upwards if the target experience scale is set to room or world scale
116+
// AND if we are either in editor (!XRDevicePresent) or we are on an XR device that will adjust the camera's height
117+
if ((experienceSettingsProfile.TargetExperienceScale == ExperienceScale.Room ||
118+
experienceSettingsProfile.TargetExperienceScale == ExperienceScale.World) &&
119+
(!DeviceUtility.IsPresent || experienceAdjustedByXRDevice))
120+
{
121+
contentPosition.x = containerObject.position.x;
122+
contentPosition.y = containerObject.position.y + experienceSettingsProfile.ContentOffset;
123+
contentPosition.z = containerObject.position.z;
124+
125+
containerObject.position = contentPosition;
126+
}
127+
break;
128+
case AlignmentType.AlignWithHeadHeight:
118129
contentPosition.x = containerObject.position.x;
119-
contentPosition.y = containerObject.position.y + experienceSettingsProfile.ContentOffset;
130+
contentPosition.y = containerObject.position.y + CameraCache.Main.transform.position.y;
120131
contentPosition.z = containerObject.position.z;
121132

122133
containerObject.position = contentPosition;
123-
}
134+
break;
135+
case AlignmentType.AlignWithHeadPose:
136+
ReorientContent();
137+
break;
124138
}
125139

126-
if (alignmentType == AlignmentType.AlignWithHeadHeight)
127-
{
128-
contentPosition.x = containerObject.position.x;
129-
contentPosition.y = containerObject.position.y + CameraCache.Main.transform.position.y;
130-
contentPosition.z = containerObject.position.z;
140+
contentInitialized = true;
141+
}
131142

132-
containerObject.position = contentPosition;
133-
}
143+
/// <summary>
144+
/// Reorients the scene content based on the camera direction
145+
/// </summary>
146+
public void ReorientContent()
147+
{
148+
contentPosition.x = CameraCache.Main.transform.localPosition.x;
149+
contentPosition.y = CameraCache.Main.transform.localPosition.y;
150+
contentPosition.z = CameraCache.Main.transform.localPosition.z;
134151

135-
contentInitialized = true;
152+
contentOrientation.y = CameraCache.Main.transform.rotation.y;
153+
contentOrientation.w = CameraCache.Main.transform.rotation.w;
154+
155+
containerObject.localPosition = contentPosition;
156+
containerObject.localRotation = contentOrientation;
136157
}
137158
}
138159
}

Assets/MRTK/Examples/Demos/EyeTracking/Scenes/EyeTrackingDemo-02-TargetSelection.unity

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,15 +1057,15 @@ RectTransform:
10571057
m_PrefabAsset: {fileID: 0}
10581058
m_GameObject: {fileID: 1432764264}
10591059
m_LocalRotation: {x: -0, y: 0.000000119209275, z: -0, w: 1}
1060-
m_LocalPosition: {x: 0, y: 0, z: 1}
1060+
m_LocalPosition: {x: 0, y: 0, z: 2.072}
10611061
m_LocalScale: {x: 0.00641, y: 0.00641, z: 0.00641}
10621062
m_Children: []
10631063
m_Father: {fileID: 3555622486023366060}
10641064
m_RootOrder: 0
10651065
m_LocalEulerAnglesHint: {x: 0, y: 135, z: 0}
10661066
m_AnchorMin: {x: 0.5, y: 0.5}
10671067
m_AnchorMax: {x: 0.5, y: 0.5}
1068-
m_AnchoredPosition: {x: -0.033, y: 0.088}
1068+
m_AnchoredPosition: {x: -0.033, y: -0.0069999993}
10691069
m_SizeDelta: {x: 20, y: 5}
10701070
m_Pivot: {x: 0.5, y: 0.5}
10711071
--- !u!114 &1432764266
@@ -1484,12 +1484,12 @@ PrefabInstance:
14841484
- target: {fileID: 7614231225992287547, guid: 18470d71939382448be2ecd06efa9662,
14851485
type: 3}
14861486
propertyPath: m_LocalPosition.y
1487-
value: 0.097
1487+
value: 0.002000004
14881488
objectReference: {fileID: 0}
14891489
- target: {fileID: 7614231225992287547, guid: 18470d71939382448be2ecd06efa9662,
14901490
type: 3}
14911491
propertyPath: m_LocalPosition.z
1492-
value: 0.844
1492+
value: 1.916
14931493
objectReference: {fileID: 0}
14941494
- target: {fileID: 7614231225992287547, guid: 18470d71939382448be2ecd06efa9662,
14951495
type: 3}
@@ -1638,15 +1638,15 @@ RectTransform:
16381638
m_PrefabAsset: {fileID: 0}
16391639
m_GameObject: {fileID: 1760202118}
16401640
m_LocalRotation: {x: -0, y: 0.000000119209275, z: -0, w: 1}
1641-
m_LocalPosition: {x: 0, y: 0, z: 1}
1641+
m_LocalPosition: {x: 0, y: 0, z: 2.072}
16421642
m_LocalScale: {x: 0.00641, y: 0.00641, z: 0.00641}
16431643
m_Children: []
16441644
m_Father: {fileID: 3555622486023366060}
16451645
m_RootOrder: 1
16461646
m_LocalEulerAnglesHint: {x: 0, y: 135, z: 0}
16471647
m_AnchorMin: {x: 0.5, y: 0.5}
16481648
m_AnchorMax: {x: 0.5, y: 0.5}
1649-
m_AnchoredPosition: {x: -0.033, y: 0.038}
1649+
m_AnchoredPosition: {x: -0.033, y: -0.057}
16501650
m_SizeDelta: {x: 20, y: 5}
16511651
m_Pivot: {x: 0.5, y: 0.5}
16521652
--- !u!114 &1760202120
@@ -2424,7 +2424,7 @@ MonoBehaviour:
24242424
m_Script: {fileID: 11500000, guid: c65c9dd2f312b8d41b8849d58e1053fa, type: 3}
24252425
m_Name:
24262426
m_EditorClassIdentifier:
2427-
alignmentType: 0
2427+
alignmentType: 2
24282428
containerObject: {fileID: 0}
24292429
--- !u!1 &3554391572042510770
24302430
GameObject:
@@ -2492,7 +2492,7 @@ Transform:
24922492
m_PrefabAsset: {fileID: 0}
24932493
m_GameObject: {fileID: 3555413705824588717}
24942494
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
2495-
m_LocalPosition: {x: 0, y: 0, z: 2}
2495+
m_LocalPosition: {x: 0, y: -0.095, z: 3.072}
24962496
m_LocalScale: {x: 1, y: 1, z: 1}
24972497
m_Children: []
24982498
m_Father: {fileID: 3555622486023366060}
@@ -2522,7 +2522,7 @@ Transform:
25222522
m_PrefabAsset: {fileID: 0}
25232523
m_GameObject: {fileID: 3555413706826911797}
25242524
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
2525-
m_LocalPosition: {x: 0, y: 0, z: 2}
2525+
m_LocalPosition: {x: 0, y: -0.095, z: 3.072}
25262526
m_LocalScale: {x: 1, y: 1, z: 1}
25272527
m_Children:
25282528
- {fileID: 325685550709208139}
@@ -2540,7 +2540,7 @@ Transform:
25402540
m_PrefabAsset: {fileID: 0}
25412541
m_GameObject: {fileID: 3554261976334479084}
25422542
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
2543-
m_LocalPosition: {x: 0, y: -0.05, z: 1}
2543+
m_LocalPosition: {x: 0, y: 0, z: 0}
25442544
m_LocalScale: {x: 1, y: 1, z: 1}
25452545
m_Children:
25462546
- {fileID: 1432764265}
@@ -2561,7 +2561,7 @@ Transform:
25612561
m_PrefabAsset: {fileID: 0}
25622562
m_GameObject: {fileID: 3554391572042510770}
25632563
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
2564-
m_LocalPosition: {x: 0.177, y: -0.227, z: 0.986}
2564+
m_LocalPosition: {x: 0.177, y: -0.322, z: 2.058}
25652565
m_LocalScale: {x: 1, y: 1, z: 1}
25662566
m_Children:
25672567
- {fileID: 4961919312122476263}
@@ -2577,7 +2577,7 @@ Transform:
25772577
m_PrefabAsset: {fileID: 0}
25782578
m_GameObject: {fileID: 3554251565221519490}
25792579
m_LocalRotation: {x: 0, y: 0, z: 0.9848078, w: 0.17364825}
2580-
m_LocalPosition: {x: 0, y: 0, z: 2.5}
2580+
m_LocalPosition: {x: 0, y: -0.095, z: 3.572}
25812581
m_LocalScale: {x: 1, y: 1, z: 1}
25822582
m_Children: []
25832583
m_Father: {fileID: 3555622486023366060}

Assets/MRTK/Examples/Demos/EyeTracking/Scenes/EyeTrackingDemo-03-Navigation.unity

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ MonoBehaviour:
355355
m_Script: {fileID: 11500000, guid: c65c9dd2f312b8d41b8849d58e1053fa, type: 3}
356356
m_Name:
357357
m_EditorClassIdentifier:
358-
alignmentType: 0
358+
alignmentType: 2
359359
containerObject: {fileID: 0}
360360
--- !u!1001 &63132508
361361
PrefabInstance:
@@ -1604,13 +1604,13 @@ MonoBehaviour:
16041604
m_margin: {x: 0, y: 0, z: -15.30367, w: -14.342575}
16051605
m_textInfo:
16061606
textComponent: {fileID: 115070431}
1607-
characterCount: 0
1607+
characterCount: 91
16081608
spriteCount: 0
1609-
spaceCount: 0
1610-
wordCount: 0
1609+
spaceCount: 16
1610+
wordCount: 16
16111611
linkCount: 0
1612-
lineCount: 0
1613-
pageCount: 0
1612+
lineCount: 3
1613+
pageCount: 1
16141614
materialCount: 1
16151615
m_isUsingLegacyAnimationComponent: 0
16161616
m_isVolumetricText: 0
@@ -1926,13 +1926,13 @@ MonoBehaviour:
19261926
m_margin: {x: 0, y: 0, z: -15.30367, w: -3.88032}
19271927
m_textInfo:
19281928
textComponent: {fileID: 127616191}
1929-
characterCount: 0
1929+
characterCount: 89
19301930
spriteCount: 0
1931-
spaceCount: 0
1932-
wordCount: 0
1931+
spaceCount: 15
1932+
wordCount: 16
19331933
linkCount: 0
1934-
lineCount: 0
1935-
pageCount: 0
1934+
lineCount: 3
1935+
pageCount: 1
19361936
materialCount: 1
19371937
m_isUsingLegacyAnimationComponent: 0
19381938
m_isVolumetricText: 0
@@ -2607,13 +2607,13 @@ MonoBehaviour:
26072607
m_margin: {x: 0, y: 0, z: -9.175957, w: 0}
26082608
m_textInfo:
26092609
textComponent: {fileID: 231954696}
2610-
characterCount: 0
2610+
characterCount: 48
26112611
spriteCount: 0
2612-
spaceCount: 0
2613-
wordCount: 0
2612+
spaceCount: 6
2613+
wordCount: 7
26142614
linkCount: 0
2615-
lineCount: 0
2616-
pageCount: 0
2615+
lineCount: 2
2616+
pageCount: 1
26172617
materialCount: 1
26182618
m_isUsingLegacyAnimationComponent: 0
26192619
m_isVolumetricText: 0
@@ -5509,13 +5509,13 @@ MonoBehaviour:
55095509
m_margin: {x: 0, y: 0, z: -28.694397, w: -14.342575}
55105510
m_textInfo:
55115511
textComponent: {fileID: 971199808}
5512-
characterCount: 0
5512+
characterCount: 307
55135513
spriteCount: 0
5514-
spaceCount: 0
5515-
wordCount: 0
5514+
spaceCount: 62
5515+
wordCount: 59
55165516
linkCount: 0
5517-
lineCount: 0
5518-
pageCount: 0
5517+
lineCount: 9
5518+
pageCount: 1
55195519
materialCount: 1
55205520
m_isUsingLegacyAnimationComponent: 0
55215521
m_isVolumetricText: 0
@@ -6092,13 +6092,13 @@ MonoBehaviour:
60926092
m_margin: {x: 0, y: 0, z: -15.426361, w: 0}
60936093
m_textInfo:
60946094
textComponent: {fileID: 1174330773}
6095-
characterCount: 0
6095+
characterCount: 30
60966096
spriteCount: 0
6097-
spaceCount: 0
6098-
wordCount: 0
6097+
spaceCount: 2
6098+
wordCount: 3
60996099
linkCount: 0
6100-
lineCount: 0
6101-
pageCount: 0
6100+
lineCount: 2
6101+
pageCount: 1
61026102
materialCount: 1
61036103
m_isUsingLegacyAnimationComponent: 0
61046104
m_isVolumetricText: 0
@@ -6583,13 +6583,13 @@ MonoBehaviour:
65836583
m_margin: {x: 0, y: 0, z: -15.177133, w: 0}
65846584
m_textInfo:
65856585
textComponent: {fileID: 1273851901}
6586-
characterCount: 0
6586+
characterCount: 15
65876587
spriteCount: 0
6588-
spaceCount: 0
6589-
wordCount: 0
6588+
spaceCount: 2
6589+
wordCount: 3
65906590
linkCount: 0
6591-
lineCount: 0
6592-
pageCount: 0
6591+
lineCount: 1
6592+
pageCount: 1
65936593
materialCount: 1
65946594
m_isUsingLegacyAnimationComponent: 0
65956595
m_isVolumetricText: 0
@@ -7519,13 +7519,13 @@ MonoBehaviour:
75197519
m_margin: {x: 0, y: 0, z: -15.426361, w: 0}
75207520
m_textInfo:
75217521
textComponent: {fileID: 1435622156}
7522-
characterCount: 0
7522+
characterCount: 24
75237523
spriteCount: 0
7524-
spaceCount: 0
7525-
wordCount: 0
7524+
spaceCount: 3
7525+
wordCount: 3
75267526
linkCount: 0
7527-
lineCount: 0
7528-
pageCount: 0
7527+
lineCount: 2
7528+
pageCount: 1
75297529
materialCount: 1
75307530
m_isUsingLegacyAnimationComponent: 0
75317531
m_isVolumetricText: 0
@@ -8395,13 +8395,13 @@ MonoBehaviour:
83958395
m_margin: {x: -1.2789195, y: 0, z: -14.308076, w: -25.542933}
83968396
m_textInfo:
83978397
textComponent: {fileID: 1485732672}
8398-
characterCount: 0
8398+
characterCount: 275
83998399
spriteCount: 0
8400-
spaceCount: 0
8401-
wordCount: 0
8400+
spaceCount: 55
8401+
wordCount: 55
84028402
linkCount: 0
8403-
lineCount: 0
8404-
pageCount: 0
8403+
lineCount: 10
8404+
pageCount: 1
84058405
materialCount: 1
84068406
m_isUsingLegacyAnimationComponent: 0
84078407
m_isVolumetricText: 0
@@ -10281,14 +10281,14 @@ MonoBehaviour:
1028110281
m_margin: {x: 5, y: 5, z: 5, w: 5}
1028210282
m_textInfo:
1028310283
textComponent: {fileID: 1852894735}
10284-
characterCount: 0
10284+
characterCount: 2035
1028510285
spriteCount: 0
10286-
spaceCount: 0
10287-
wordCount: 0
10286+
spaceCount: 394
10287+
wordCount: 331
1028810288
linkCount: 0
10289-
lineCount: 0
10290-
pageCount: 0
10291-
materialCount: 1
10289+
lineCount: 51
10290+
pageCount: 1
10291+
materialCount: 2
1029210292
m_isUsingLegacyAnimationComponent: 0
1029310293
m_isVolumetricText: 0
1029410294
m_spriteAnimator: {fileID: 0}

Assets/MRTK/Examples/Demos/EyeTracking/Scenes/EyeTrackingDemo-04-TargetPositioning.unity

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ MonoBehaviour:
159159
m_Script: {fileID: 11500000, guid: c65c9dd2f312b8d41b8849d58e1053fa, type: 3}
160160
m_Name:
161161
m_EditorClassIdentifier:
162-
alignmentType: 0
162+
alignmentType: 2
163163
containerObject: {fileID: 0}
164164
--- !u!1 &25280373
165165
GameObject:

0 commit comments

Comments
 (0)