Skip to content

Commit 0ce27d8

Browse files
author
davidkline-ms
committed
Merge remote-tracking branch 'upstream/main'
2 parents e114452 + 8acbb64 commit 0ce27d8

File tree

41 files changed

+514
-189
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+514
-189
lines changed

Assets/MRTK/Core/Inspectors/ControllerPopupWindow.cs

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -316,40 +316,13 @@ private void RenderMappingList(List<string> controllerList)
316316
return;
317317
}
318318

319-
GUIStyle headerStyle = new GUIStyle();
320-
headerStyle.richText = true;
321-
322-
if (currentControllerOption == null || currentControllerTexture == null)
319+
using (new EditorGUILayout.VerticalScope())
323320
{
324-
GUILayout.BeginVertical();
325-
using (new EditorGUILayout.VerticalScope())
326-
{
327-
GUILayout.FlexibleSpace();
328-
EditorGUILayout.LabelField("<b>Controllers affected by this mapping</b>", headerStyle);
329-
for (int i = 0; i < controllerList.Count; i++)
330-
{
331-
EditorGUILayout.LabelField(controllerList[i]);
332-
}
333-
}
334-
GUILayout.EndVertical();
335-
}
336-
else
337-
{
338-
float max_y = currentControllerOption.InputLabelPositions.Max(x => x.y);
339-
340-
var titleRectPosition = Vector2.up * (max_y + 4 * EditorGUIUtility.singleLineHeight);
341-
var titleRectSize = new Vector2(500, EditorGUIUtility.singleLineHeight);
342-
343-
var titleRect = new Rect(titleRectPosition, titleRectSize);
344-
EditorGUI.LabelField(titleRect, "<b>Controllers affected by this mapping</b>", headerStyle);
345-
321+
GUILayout.FlexibleSpace();
322+
EditorGUILayout.LabelField("Controllers affected by this mapping", EditorStyles.boldLabel);
346323
for (int i = 0; i < controllerList.Count; i++)
347324
{
348-
var rectPosition = Vector2.up * (max_y + (i + 5) * EditorGUIUtility.singleLineHeight);
349-
var rectSize = new Vector2(1000, EditorGUIUtility.singleLineHeight);
350-
351-
var labelRect = new Rect(rectPosition, rectSize);
352-
EditorGUI.LabelField(labelRect, controllerList[i]);
325+
EditorGUILayout.LabelField(controllerList[i]);
353326
}
354327
}
355328
}

Assets/MRTK/Core/Inspectors/MixedRealityToolkitInspector.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ public class MixedRealityToolkitInspector : UnityEditor.Editor
1212
{
1313
private SerializedProperty activeProfile;
1414
private UnityEditor.Editor activeProfileEditor;
15+
private Object cachedProfile;
1516

1617
private void OnEnable()
1718
{
1819
activeProfile = serializedObject.FindProperty("activeProfile");
20+
cachedProfile = activeProfile.objectReferenceValue;
1921
}
2022

2123
public override void OnInspectorGUI()
@@ -53,14 +55,16 @@ public override void OnInspectorGUI()
5355
EditorGUILayout.HelpBox("MixedRealityToolkit cannot initialize unless an Active Profile is assigned!", MessageType.Error);
5456
}
5557

56-
bool changed = MixedRealityInspectorUtility.DrawProfileDropDownList(activeProfile, null, activeProfile.objectReferenceValue, typeof(MixedRealityToolkitConfigurationProfile), false, false);
58+
bool changed = MixedRealityInspectorUtility.DrawProfileDropDownList(activeProfile, null, activeProfile.objectReferenceValue, typeof(MixedRealityToolkitConfigurationProfile), false, false) ||
59+
cachedProfile != activeProfile.objectReferenceValue;
5760

5861
serializedObject.ApplyModifiedProperties();
5962

6063
if (changed)
6164
{
6265
MixedRealityToolkit.Instance.ResetConfiguration((MixedRealityToolkitConfigurationProfile)activeProfile.objectReferenceValue);
6366
activeProfileEditor = null;
67+
cachedProfile = activeProfile.objectReferenceValue;
6468
}
6569

6670
if (activeProfile.objectReferenceValue != null && activeProfileEditor == null)

Assets/MRTK/Core/Inspectors/Profiles/MixedRealityToolkitConfigurationProfileInspector.cs

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ public class MixedRealityToolkitConfigurationProfileInspector : BaseMixedReality
2121
private static readonly GUIContent TargetScaleContent = new GUIContent("Target Scale:");
2222

2323
// Experience properties
24-
private SerializedProperty experienceSettingsType;
2524
private SerializedProperty experienceSettingsProfile;
2625

2726
// Tracking the old experience scale property for compatibility
@@ -97,7 +96,6 @@ protected override void OnEnable()
9796
MixedRealityToolkitConfigurationProfile mrtkConfigProfile = target as MixedRealityToolkitConfigurationProfile;
9897

9998
// Experience configuration
100-
experienceSettingsType = serializedObject.FindProperty("experienceSettingsType");
10199
experienceSettingsProfile = serializedObject.FindProperty("experienceSettingsProfile");
102100
experienceScaleMigration = serializedObject.FindProperty("targetExperienceScale");
103101

@@ -153,21 +151,32 @@ protected override void OnEnable()
153151
using (var c = new EditorGUI.ChangeCheckScope())
154152
{
155153
// Reconciling old Experience Scale property with the Experience Settings Profile
156-
var oldExperienceSettigsScale = (experienceSettingsProfile.objectReferenceValue as MixedRealityExperienceSettingsProfile)?.TargetExperienceScale;
154+
ExperienceScale? oldExperienceSettingsScale = null;
155+
if (experienceSettingsProfile.objectReferenceValue is MixedRealityExperienceSettingsProfile oldExperienceSettingsProfile
156+
&& oldExperienceSettingsProfile != null)
157+
{
158+
oldExperienceSettingsScale = oldExperienceSettingsProfile.TargetExperienceScale;
159+
}
157160

158-
changed |= RenderProfile(experienceSettingsProfile, typeof(MixedRealityExperienceSettingsProfile), true, false, null, true);
161+
changed |= RenderProfile(experienceSettingsProfile, typeof(MixedRealityExperienceSettingsProfile), true, false, null);
159162

160163
// Experience configuration
161-
if(!mrtkConfigProfile.ExperienceSettingsProfile.IsNull())
162-
{
164+
if (mrtkConfigProfile.ExperienceSettingsProfile != null)
165+
{
163166
// If the Experience Scale property changed, make sure we also alter the configuration profile's target experience scale property for compatibility
164-
var newExperienceSettigs = (experienceSettingsProfile.objectReferenceValue as MixedRealityExperienceSettingsProfile)?.TargetExperienceScale;
165-
if(oldExperienceSettigsScale.HasValue && newExperienceSettigs.HasValue && oldExperienceSettigsScale != newExperienceSettigs)
167+
ExperienceScale? newExperienceSettingsScale = null;
168+
if (experienceSettingsProfile.objectReferenceValue is MixedRealityExperienceSettingsProfile newExperienceSettingsProfile
169+
&& newExperienceSettingsProfile != null)
170+
{
171+
newExperienceSettingsScale = newExperienceSettingsProfile.TargetExperienceScale;
172+
}
173+
174+
if (oldExperienceSettingsScale.HasValue && newExperienceSettingsScale.HasValue && oldExperienceSettingsScale != newExperienceSettingsScale)
166175
{
167-
experienceScaleMigration.intValue = (int)newExperienceSettigs;
176+
experienceScaleMigration.intValue = (int)newExperienceSettingsScale;
168177
experienceScaleMigration.serializedObject.ApplyModifiedProperties();
169178
}
170-
// If we have not changed the Experience Settings profile and it's value is out of sync with the top level configuration profile, display a migration prompt
179+
// If we have not changed the Experience Settings profile and its value is out of sync with the top level configuration profile, display a migration prompt
171180
else if ((ExperienceScale)experienceScaleMigration.intValue != mrtkConfigProfile.ExperienceSettingsProfile.TargetExperienceScale)
172181
{
173182
Color errorColor = Color.Lerp(Color.white, Color.red, 0.5f);
@@ -247,14 +256,24 @@ protected override void OnEnable()
247256
return changed;
248257
},
249258
() => {
250-
var experienceScale = mrtkConfigProfile.ExperienceSettingsProfile.TargetExperienceScale;
251-
if (experienceScale != ExperienceScale.Room)
259+
if(mrtkConfigProfile.ExperienceSettingsProfile.IsNull())
252260
{
253-
// Alert the user if the experience scale does not support boundary features.
261+
// Alert that an experience settings profile has not been selected
254262
GUILayout.Space(6f);
255-
EditorGUILayout.HelpBox("Boundaries are only supported in Room scale experiences.", MessageType.Warning);
263+
EditorGUILayout.HelpBox("Boundaries require an experience settings profile with a Room scale target experience scale.", MessageType.Warning);
256264
GUILayout.Space(6f);
257265
}
266+
else
267+
{
268+
var experienceScale = mrtkConfigProfile.ExperienceSettingsProfile.TargetExperienceScale;
269+
if (experienceScale != ExperienceScale.Room)
270+
{
271+
// Alert the user if the experience scale does not support boundary features.
272+
GUILayout.Space(6f);
273+
EditorGUILayout.HelpBox("Boundaries are only supported in Room scale experiences.", MessageType.Warning);
274+
GUILayout.Space(6f);
275+
}
276+
}
258277

259278
bool changed = false;
260279
using (var c = new EditorGUI.ChangeCheckScope())
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
using Microsoft.MixedReality.Toolkit.Utilities.Editor;
5+
using System;
6+
using UnityEditor;
7+
using UnityEngine;
8+
9+
namespace Microsoft.MixedReality.Toolkit.Editor
10+
{
11+
internal class MRTKVersionPopup : EditorWindow
12+
{
13+
private const string DefaultVersion = "0.0.0.0";
14+
private const string NotFoundMessage = "The version could not be read. This is most often due to (and expected when) using MRTK directly from the repo. If you're using an official distribution and seeing this message, please file a GitHub issue!";
15+
private static readonly Version MRTKVersion = typeof(MixedRealityToolkit).Assembly.GetName().Version;
16+
private static readonly bool FoundVersion = MRTKVersion.ToString() != DefaultVersion;
17+
private static readonly Vector2 WindowSize = new Vector2(300, 140);
18+
private static readonly Vector2 NotFoundWindowSize = new Vector2(300, 175);
19+
private static readonly GUIContent Title = new GUIContent("Mixed Reality Toolkit");
20+
private static MRTKVersionPopup window;
21+
22+
[MenuItem("Mixed Reality/Toolkit/Show version...", priority = int.MaxValue)]
23+
private static void Init()
24+
{
25+
if (window != null)
26+
{
27+
window.ShowUtility();
28+
return;
29+
}
30+
31+
window = CreateInstance<MRTKVersionPopup>();
32+
window.titleContent = Title;
33+
window.maxSize = FoundVersion ? WindowSize : NotFoundWindowSize;
34+
window.minSize = FoundVersion ? WindowSize : NotFoundWindowSize;
35+
window.ShowUtility();
36+
}
37+
38+
private void OnGUI()
39+
{
40+
using (new EditorGUILayout.VerticalScope())
41+
{
42+
MixedRealityInspectorUtility.RenderMixedRealityToolkitLogo();
43+
44+
using (new EditorGUILayout.HorizontalScope())
45+
{
46+
GUILayout.FlexibleSpace();
47+
EditorGUILayout.LabelField(FoundVersion ? $"Version {MRTKVersion}" : NotFoundMessage, EditorStyles.wordWrappedLabel);
48+
GUILayout.FlexibleSpace();
49+
}
50+
}
51+
}
52+
}
53+
}

Assets/MRTK/Core/Inspectors/Setup/MRTKVersionPopup.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/MRTK/Core/Inspectors/Utilities/InspectorUIUtility.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,11 @@ static public bool DrawScriptableFoldout<T>(SerializedProperty scriptable, strin
650650
else
651651
{
652652
bool isNestedInCurrentPrefab = false;
653-
var prefabStage = PrefabStageUtility.GetCurrentPrefabStage();
653+
#if UNITY_2021_2_OR_NEWER
654+
var prefabStage = UnityEditor.SceneManagement.PrefabStageUtility.GetCurrentPrefabStage();
655+
#else
656+
var prefabStage = UnityEditor.Experimental.SceneManagement.PrefabStageUtility.GetCurrentPrefabStage();
657+
#endif
654658
if (prefabStage != null)
655659
{
656660
var instancePath = AssetDatabase.GetAssetPath(scriptable.objectReferenceValue);

Assets/MRTK/Core/Providers/UnityInput/UnityJoystickManager.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ namespace Microsoft.MixedReality.Toolkit.Input.UnityInput
1717
[MixedRealityDataProvider(
1818
typeof(IMixedRealityInputSystem),
1919
(SupportedPlatforms)(-1), // All platforms supported by Unity
20-
"Unity Joystick Manager",
21-
supportedUnityXRPipelines: SupportedUnityXRPipelines.LegacyXR)]
20+
"Unity Joystick Manager")]
2221
#if UNITY_2020_1_OR_NEWER
2322
[Obsolete("The legacy XR pipeline has been removed in Unity 2020 or newer. Please migrate to XR SDK.")]
2423
#endif // UNITY_2020_1_OR_NEWER

Assets/MRTK/Core/Utilities/BuildAndDeploy/UwpAppxBuildTools.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,11 @@ public static void AddCapabilities(IBuildInfo buildInfo, XElement rootElement =
531531
AddGazeInputCapability(rootElement);
532532
}
533533

534-
if (uwpBuildInfo.ResearchModeCapabilityEnabled && EditorUserBuildSettings.wsaSubtarget == WSASubtarget.HoloLens)
534+
if (uwpBuildInfo.ResearchModeCapabilityEnabled
535+
#if !UNITY_2021_2_OR_NEWER
536+
&& EditorUserBuildSettings.wsaSubtarget == WSASubtarget.HoloLens
537+
#endif // !UNITY_2021_2_OR_NEWER
538+
)
535539
{
536540
AddResearchModeCapability(rootElement);
537541
}

0 commit comments

Comments
 (0)