Skip to content

Commit 4011eeb

Browse files
author
davidkline-ms
committed
add xrsettingsutilities to reduce pragmas for warning 0618
1 parent da719df commit 4011eeb

File tree

8 files changed

+71
-18
lines changed

8 files changed

+71
-18
lines changed

Assets/MixedRealityToolkit.Services/InputSystem/Editor/Microsoft.MixedReality.Toolkit.Services.InputSystem.Editor.asmdef

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "Microsoft.MixedReality.Toolkit.Services.InputSystem.Editor",
33
"references": [
4+
"Microsoft.MixedReality.Toolkit.Editor.Utilities",
45
"Microsoft.MixedReality.Toolkit",
56
"Microsoft.MixedReality.Toolkit.Services.InputSystem"
67
],

Assets/MixedRealityToolkit.Services/InputSystem/Editor/MixedRealityCanvasInspector.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using Microsoft.MixedReality.Toolkit.Input.Utilities;
55
using Microsoft.MixedReality.Toolkit.Utilities;
6+
using Microsoft.MixedReality.Toolkit.Utilities.Editor;
67
using System.Collections.Generic;
78
using System.Linq;
89
using System.Reflection;
@@ -19,7 +20,7 @@ namespace Microsoft.MixedReality.Toolkit.Input
1920

2021
[CanEditMultipleObjects]
2122
[CustomEditor(typeof(Canvas))]
22-
public class MixedRealityCanvasInspector : Editor
23+
public class MixedRealityCanvasInspector : UnityEditor.Editor
2324
{
2425
private static readonly GUIContent makeMRTKCanvas = new GUIContent("Convert to MRTK Canvas", "Configures the GameObject for MRKT use:\n1. Switches Canvas to world space\n2. Removes world space Camera\n3. Ensures GraphicRaycaster component\n4. Ensures CanvasUtility component");
2526
private static readonly GUIContent removeMRTKCanvas = new GUIContent("Convert to Unity Canvas", "Configures the GameObject for regular use:\n1. Removes CanvasUtility component\n2. Removes NearInteractionTouchableUnityUI component");
@@ -162,12 +163,7 @@ private void AllRootCanvases()
162163
}
163164

164165
EditorGUILayout.Space();
165-
166-
// Ensure compatibility with the pre-2019.3 XR architecture for customers / platforms
167-
// with legacy requirements.
168-
#pragma warning disable 0618
169-
if (PlayerSettings.virtualRealitySupported &&
170-
#pragma warning restore 0618
166+
if (XRSettingsUtilities.LegacyXREnabled &&
171167
(m_RenderMode.enumValueIndex == (int)RenderMode.ScreenSpaceOverlay))
172168
{
173169
EditorGUILayout.HelpBox("Using a render mode of ScreenSpaceOverlay while VR is enabled will cause the Canvas to continue to incur a rendering cost, even though the Canvas will not be visible in VR.", MessageType.Warning);

Assets/MixedRealityToolkit.Services/InputSystem/Editor/NearInteractionTouchableInspector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public override void OnInspectorGUI()
8989
}
9090

9191
[CustomEditor(typeof(BaseNearInteractionTouchable), true)]
92-
public class NearInteractionTouchableInspectorBase : Editor
92+
public class NearInteractionTouchableInspectorBase : UnityEditor.Editor
9393
{
9494
private readonly Color handleColor = Color.white;
9595
private readonly Color fillColor = new Color(0, 0, 0, 0);

Assets/MixedRealityToolkit.Tools/OptimizeWindow/MixedRealityOptimizeWindow.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,18 +133,14 @@ private void OnGUI()
133133
EditorGUILayout.HelpBox(PerformanceTargetDescriptions[(int)PerfTarget], MessageType.Info);
134134
EditorGUILayout.Space();
135135

136-
// Ensure compatibility with the pre-2019.3 XR architecture for customers / platforms
137-
// with legacy requirements.
138-
#pragma warning disable 0618
139-
if (!PlayerSettings.virtualRealitySupported)
136+
if (!XRSettingsUtilities.LegacyXREnabled)
140137
{
141138
EditorGUILayout.HelpBox("Virtual reality support is not enabled in player settings", MessageType.Error);
142139
if (GUILayout.Button("Enable Virtual Reality Support"))
143140
{
144-
PlayerSettings.virtualRealitySupported = true;
141+
XRSettingsUtilities.LegacyXREnabled = true;
145142
}
146143
}
147-
#pragma warning disable 0618
148144
else
149145
{
150146
selectedToolbarIndex = GUILayout.Toolbar(selectedToolbarIndex, ToolbarTitles);

Assets/MixedRealityToolkit/Inspectors/Setup/MixedRealityEditorSettings.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,7 @@ private static void LogConfigurationWarnings()
8383
{
8484
// Ensure compatibility with the pre-2019.3 XR architecture for customers / platforms
8585
// with legacy requirements.
86-
#pragma warning disable 0618
87-
if (!PlayerSettings.virtualRealitySupported)
88-
#pragma warning restore 0618
86+
if (!XRSettingsUtilities.LegacyXREnabled)
8987
{
9088
Debug.LogWarning("<b>Virtual reality supported</b> not enabled. Check <i>XR Settings</i> under <i>Player Settings</i>");
9189
}

Assets/MixedRealityToolkit/Inspectors/Setup/MixedRealityProjectConfiguratorWindow.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ private void RenderConfigurations()
159159
{
160160
using (new EditorGUI.IndentLevelScope())
161161
{
162-
// todo
163162
RenderToggle(MRConfig.XRManagerWindows, "Windows XR");
164163
RenderToggle(MRConfig.XRManagerOculus, "Oculus XR");
165164
RenderToggle(MRConfig.XRManagerAndroid, "Android ARCore XR");
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
using System.Collections.Generic;
5+
using UnityEditor;
6+
using UnityEngine;
7+
8+
#if UNITY_2019_3_OR_NEWER
9+
using UnityEditor.PackageManager;
10+
using UnityEditor.PackageManager.Requests;
11+
using PackageInfo = UnityEditor.PackageManager.PackageInfo;
12+
#endif // UNITY_2019_3_OR_NEWER
13+
14+
#if XR_MANAGEMENT_ENABLED
15+
using System.Threading;
16+
using UnityEngine.XR.Management;
17+
#endif //XR_MANAGEMENT_ENABLED
18+
19+
namespace Microsoft.MixedReality.Toolkit.Utilities.Editor
20+
{
21+
/// <summary>
22+
/// Utilities that abstract XR settings functionality so that the MRTK need not know which
23+
/// implementation is being used.
24+
/// </summary>
25+
public static class XRSettingsUtilities
26+
{
27+
/// <summary>
28+
/// Gets or sets the legacy virtual reality supported property in the player settings object.
29+
/// </summary>
30+
public static bool LegacyXREnabled
31+
{
32+
get
33+
{
34+
// Ensure compatibility with the pre-2019.3 XR architecture for customers / platforms
35+
// with legacy requirements.
36+
#pragma warning disable 0618
37+
return PlayerSettings.virtualRealitySupported;
38+
#pragma warning restore 0618
39+
}
40+
41+
set
42+
{
43+
// Ensure compatibility with the pre-2019.3 XR architecture for customers / platforms
44+
// with legacy requirements.
45+
#pragma warning disable 0618
46+
PlayerSettings.virtualRealitySupported = value;
47+
#pragma warning restore 0618
48+
}
49+
}
50+
51+
}
52+
}

Assets/MixedRealityToolkit/Utilities/Editor/XRSettingsUtilities.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.

0 commit comments

Comments
 (0)