Skip to content

Commit d2aaa45

Browse files
authored
Merge pull request #6990 from keveleigh/xr-sdk-cherrypicks
BaseSpatialMeshObserver and MixedRealityOptimizeUtils updates for XR SDK
2 parents eee7a55 + abe4c37 commit d2aaa45

File tree

6 files changed

+31
-28
lines changed

6 files changed

+31
-28
lines changed

Assets/MixedRealityToolkit.SDK/Profiles/HoloLens2/DefaultHoloLens2ConfigurationProfile.asset

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,4 @@ MonoBehaviour:
5252
registeredServiceProvidersProfile: {fileID: 11400000, guid: efbaf6ea540c69f4fb75415a5d145a53,
5353
type: 2}
5454
useServiceInspectors: 1
55+
renderDepthBuffer: 0

Assets/MixedRealityToolkit.Tests/PlayModeTests/SpatialObserverTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ namespace Microsoft.MixedReality.Toolkit.Tests
2525
/// </summary>
2626
public class SpatialObserverTests
2727
{
28-
private const string TestSpatialAwarenessSysteProfilePath = "Assets/MixedRealityToolkit.Tests/PlayModeTests/TestProfiles/TestMixedRealitySpatialAwarenessSystemProfile.asset";
29-
private const string TestSpatialAwarenessSysteProfilePath_ManualStart = "Assets/MixedRealityToolkit.Tests/PlayModeTests/TestProfiles/TestMixedRealitySpatialAwarenessSystemProfile_ManualStart.asset";
28+
private const string TestSpatialAwarenessSystemProfilePath = "Assets/MixedRealityToolkit.Tests/PlayModeTests/TestProfiles/TestMixedRealitySpatialAwarenessSystemProfile.asset";
29+
private const string TestSpatialAwarenessSystemProfilePath_ManualStart = "Assets/MixedRealityToolkit.Tests/PlayModeTests/TestProfiles/TestMixedRealitySpatialAwarenessSystemProfile_ManualStart.asset";
3030

3131
/// <summary>
3232
/// Test default case of Auto-Start SpatialObjectMeshObserver observer type and SpatialAwarenessSystem in editor
@@ -35,7 +35,7 @@ public class SpatialObserverTests
3535
[UnityTest]
3636
public IEnumerator TestAutoStartObserver()
3737
{
38-
var mrtkProfile = CreateMRTKTestProfile(TestSpatialAwarenessSysteProfilePath);
38+
var mrtkProfile = CreateMRTKTestProfile(TestSpatialAwarenessSystemProfilePath);
3939
TestUtilities.InitializeMixedRealityToolkit(mrtkProfile);
4040
yield return PlayModeTestUtilities.WaitForInputSystemUpdate();
4141

@@ -64,7 +64,7 @@ public IEnumerator TestAutoStartObserver()
6464
[UnityTest]
6565
public IEnumerator TestManualStartObserver()
6666
{
67-
var mrtkProfile = CreateMRTKTestProfile(TestSpatialAwarenessSysteProfilePath_ManualStart);
67+
var mrtkProfile = CreateMRTKTestProfile(TestSpatialAwarenessSystemProfilePath_ManualStart);
6868
TestUtilities.InitializeMixedRealityToolkit(mrtkProfile);
6969
yield return PlayModeTestUtilities.WaitForInputSystemUpdate();
7070

@@ -106,7 +106,7 @@ public IEnumerator TestManualStartObserver()
106106
[UnityTest]
107107
public IEnumerator TestDisableSpatialAwarenessSystem()
108108
{
109-
var mrtkProfile = CreateMRTKTestProfile(TestSpatialAwarenessSysteProfilePath);
109+
var mrtkProfile = CreateMRTKTestProfile(TestSpatialAwarenessSystemProfilePath);
110110

111111
mrtkProfile.IsSpatialAwarenessSystemEnabled = false;
112112

Assets/MixedRealityToolkit/Inspectors/Setup/MixedRealityEditorSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ private static void LogConfigurationWarnings()
9999

100100
if (!AudioSettings.GetSpatializerPluginName().Equals(MSFT_AudioSpatializerPlugin))
101101
{
102-
// If using UWP, developers should use the Microsoft Audio Spatilizer plugin
102+
// If using UWP, developers should use the Microsoft Audio Spatializer plugin
103103
Debug.LogWarning("<b>Audio Spatializer Plugin</b> not currently set to <i>" + MSFT_AudioSpatializerPlugin + "</i>. Switch to <i>" + MSFT_AudioSpatializerPlugin + "</i> under <i>Project Settings</i> > <i>Audio</i> > <i>Spatializer Plugin</i>");
104104
}
105105
}

Assets/MixedRealityToolkit/Providers/BaseSpatialMeshObserver.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ protected BaseSpatialMeshObserver(
2525
uint priority = DefaultPriority,
2626
BaseMixedRealityProfile profile = null) : base(spatialAwarenessSystem, name, priority, profile)
2727
{
28-
ReadProfile();
2928
}
3029

3130
#region BaseSpatialMeshObserver Implementation
@@ -160,7 +159,9 @@ protected virtual void ApplyUpdatedPhysicsLayer()
160159
public override void Initialize()
161160
{
162161
meshEventData = new MixedRealitySpatialAwarenessEventData<SpatialAwarenessMeshObject>(EventSystem.current);
163-
162+
163+
ReadProfile();
164+
164165
base.Initialize();
165166
}
166167

Assets/MixedRealityToolkit/Utilities/Editor/InputMappingAxisUtility.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

4+
using Microsoft.MixedReality.Toolkit.Utilities;
45
using Microsoft.MixedReality.Toolkit.Utilities.Editor;
56
using System.Collections.Generic;
67
using UnityEditor;
@@ -40,7 +41,7 @@ public static class InputMappingAxisUtility
4041
/// <param name="axisMappings">Optional array of Axis Mappings, to configure your own custom set</param>
4142
public static void CheckUnityInputManagerMappings(InputManagerAxis[] axisMappings)
4243
{
43-
AssureInputManagerReference();
44+
EnsureInputManagerReference();
4445

4546
if (axisMappings != null)
4647
{
@@ -65,7 +66,7 @@ public static void CheckUnityInputManagerMappings(InputManagerAxis[] axisMapping
6566
/// <param name="axisMappings">Optional array of Axis Mappings, to configure your own custom set</param>
6667
public static void RemoveMappings(InputManagerAxis[] axisMappings)
6768
{
68-
AssureInputManagerReference();
69+
EnsureInputManagerReference();
6970

7071
if (axisMappings != null)
7172
{
@@ -83,7 +84,7 @@ public static void RemoveMappings(InputManagerAxis[] axisMappings)
8384

8485
private static void AddAxis(InputManagerAxis axis)
8586
{
86-
AssureInputManagerReference();
87+
EnsureInputManagerReference();
8788

8889
SerializedProperty axesProperty = inputManagerAsset.FindProperty("m_Axes");
8990

@@ -149,7 +150,7 @@ private static void AddAxis(InputManagerAxis axis)
149150

150151
private static void RemoveAxis(string axis)
151152
{
152-
AssureInputManagerReference();
153+
EnsureInputManagerReference();
153154

154155
SerializedProperty axesProperty = inputManagerAsset.FindProperty("m_Axes");
155156

@@ -169,7 +170,7 @@ private static void RemoveAxis(string axis)
169170
/// </summary>
170171
public static bool DoesAxisNameExist(string axisName)
171172
{
172-
AssureInputManagerReference();
173+
EnsureInputManagerReference();
173174

174175
if (AxisNames.Count == 0 || inputManagerAsset.UpdateIfRequiredOrScript())
175176
{
@@ -184,7 +185,7 @@ public static bool DoesAxisNameExist(string axisName)
184185
/// </summary>
185186
private static void RefreshLocalAxesList()
186187
{
187-
AssureInputManagerReference();
188+
EnsureInputManagerReference();
188189

189190
AxisNames.Clear();
190191

@@ -196,12 +197,12 @@ private static void RefreshLocalAxesList()
196197
}
197198
}
198199

199-
private static void AssureInputManagerReference()
200+
private static void EnsureInputManagerReference()
200201
{
201202
if (inputManagerAsset == null)
202203
{
203204
// Grabs the actual asset file into a SerializedObject, so we can iterate through it and edit it.
204-
inputManagerAsset = new SerializedObject(AssetDatabase.LoadAssetAtPath("ProjectSettings/InputManager.asset", typeof(UnityEngine.Object)));
205+
inputManagerAsset = MixedRealityOptimizeUtils.GetSettingsObject("InputManager");
205206
}
206207
}
207208

Assets/MixedRealityToolkit/Utilities/Editor/MixedRealityOptimizeUtils.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static void SetDepthBufferSharing(bool enableDepthBuffer)
6161
}
6262
else if (IsBuildTargetUWP())
6363
{
64-
#if UNITY_2019
64+
#if UNITY_2019_1_OR_NEWER
6565
PlayerSettings.VRWindowsMixedReality.depthBufferSharingEnabled = enableDepthBuffer;
6666
#else
6767
var playerSettings = GetSettingsObject("PlayerSettings");
@@ -91,13 +91,13 @@ public static void SetDepthBufferFormat(bool set16BitDepthBuffer)
9191
PlayerSettings.VRDaydream.depthFormat = depthFormat;
9292

9393
var playerSettings = GetSettingsObject("PlayerSettings");
94-
#if UNITY_2019
95-
PlayerSettings.VRWindowsMixedReality.depthBufferFormat = set16BitDepthBuffer ?
96-
PlayerSettings.VRWindowsMixedReality.DepthBufferFormat.DepthBufferFormat16Bit :
97-
PlayerSettings.VRWindowsMixedReality.DepthBufferFormat.DepthBufferFormat24Bit;
94+
#if UNITY_2019_1_OR_NEWER
95+
PlayerSettings.VRWindowsMixedReality.depthBufferFormat = set16BitDepthBuffer ?
96+
PlayerSettings.VRWindowsMixedReality.DepthBufferFormat.DepthBufferFormat16Bit :
97+
PlayerSettings.VRWindowsMixedReality.DepthBufferFormat.DepthBufferFormat24Bit;
9898

99-
ChangeProperty(playerSettings,
100-
"vrSettings.lumin.depthFormat",
99+
ChangeProperty(playerSettings,
100+
"vrSettings.lumin.depthFormat",
101101
property => property.intValue = depthFormat);
102102
#else
103103
ChangeProperty(playerSettings,
@@ -108,27 +108,27 @@ public static void SetDepthBufferFormat(bool set16BitDepthBuffer)
108108

109109
public static bool IsRealtimeGlobalIlluminationEnabled()
110110
{
111-
var lightmapSettings = GetLighmapSettings();
111+
var lightmapSettings = GetLightmapSettings();
112112
var property = lightmapSettings?.FindProperty("m_GISettings.m_EnableRealtimeLightmaps");
113113
return property != null && property.boolValue;
114114
}
115115

116116
public static void SetRealtimeGlobalIlluminationEnabled(bool enabled)
117117
{
118-
var lightmapSettings = GetLighmapSettings();
118+
var lightmapSettings = GetLightmapSettings();
119119
ChangeProperty(lightmapSettings, "m_GISettings.m_EnableRealtimeLightmaps", property => property.boolValue = enabled);
120120
}
121121

122122
public static bool IsBakedGlobalIlluminationEnabled()
123123
{
124-
var lightmapSettings = GetLighmapSettings();
124+
var lightmapSettings = GetLightmapSettings();
125125
var property = lightmapSettings?.FindProperty("m_GISettings.m_EnableBakedLightmaps");
126126
return property != null && property.boolValue;
127127
}
128128

129129
public static void SetBakedGlobalIlluminationEnabled(bool enabled)
130130
{
131-
var lightmapSettings = GetLighmapSettings();
131+
var lightmapSettings = GetLightmapSettings();
132132
ChangeProperty(lightmapSettings, "m_GISettings.m_EnableBakedLightmaps", property => property.boolValue = enabled);
133133
}
134134

@@ -170,7 +170,7 @@ public static SerializedObject GetSettingsObject(string className)
170170
return new SerializedObject(settings);
171171
}
172172

173-
public static SerializedObject GetLighmapSettings()
173+
public static SerializedObject GetLightmapSettings()
174174
{
175175
var getLightmapSettingsMethod = typeof(LightmapEditorSettings).GetMethod("GetLightmapSettings", BindingFlags.Static | BindingFlags.NonPublic);
176176
var lightmapSettings = getLightmapSettingsMethod.Invoke(null, null) as UnityEngine.Object;

0 commit comments

Comments
 (0)