Skip to content

Commit 18a0c8b

Browse files
Pulled out Mixed Reality Manager Check and added it to base handler inspector
1 parent 2a23e02 commit 18a0c8b

File tree

5 files changed

+20
-45
lines changed

5 files changed

+20
-45
lines changed

Assets/MixedRealityToolkit-SDK/Inspectors/Input/Handlers/BaseInputHandlerInspector.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
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.Core.Inspectors.Profiles;
45
using Microsoft.MixedReality.Toolkit.Core.Managers;
56
using UnityEditor;
67

78
namespace Microsoft.MixedReality.Toolkit.SDK.Inspectors.Input.Handlers
89
{
9-
public class BaseInputHandlerInspector : Editor
10+
public class BaseInputHandlerInspector : BaseMixedRealityInspector
1011
{
1112
private SerializedProperty isFocusRequiredProperty;
1213

Assets/MixedRealityToolkit-SDK/Inspectors/Input/Handlers/PointerClickHandlerInspector.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
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.Core.Managers;
54
using Microsoft.MixedReality.Toolkit.SDK.Input.Handlers;
65
using UnityEditor;
76

@@ -22,12 +21,15 @@ protected override void OnEnable()
2221
pointerDownProperty = serializedObject.FindProperty("onPointerDownActionEvent");
2322
pointerClickedProperty = serializedObject.FindProperty("onPointerClickedActionEvent");
2423

25-
MixedRealityManager.ConfirmInitialized();
24+
CheckMixedRealityManager(false);
2625
}
2726

2827
public override void OnInspectorGUI()
2928
{
3029
base.OnInspectorGUI();
30+
31+
if (!CheckMixedRealityManager()) { return; }
32+
3133
serializedObject.Update();
3234
EditorGUILayout.PropertyField(pointerUpProperty, true);
3335
EditorGUILayout.PropertyField(pointerDownProperty, true);

Assets/MixedRealityToolkit-SDK/Inspectors/Input/Handlers/SpeechInputHandlerInspector.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,20 @@ protected override void OnEnable()
2828

2929
keywordsProperty = serializedObject.FindProperty("keywords");
3030
persistentKeywordsProperty = serializedObject.FindProperty("persistentKeywords");
31-
registeredKeywords = RegisteredKeywords().Distinct().ToArray();
31+
32+
if (CheckMixedRealityManager(false))
33+
{
34+
registeredKeywords = RegisteredKeywords().Distinct().ToArray();
35+
}
3236
}
3337

3438
public override void OnInspectorGUI()
3539
{
3640
base.OnInspectorGUI();
37-
serializedObject.Update();
41+
if (!CheckMixedRealityManager())
42+
{
43+
return;
44+
}
3845

3946
if (!MixedRealityManager.Instance.ActiveProfile.IsInputSystemEnabled)
4047
{
@@ -49,6 +56,7 @@ public override void OnInspectorGUI()
4956
return;
5057
}
5158

59+
serializedObject.Update();
5260
EditorGUILayout.PropertyField(persistentKeywordsProperty);
5361

5462
ShowList(keywordsProperty);
@@ -142,8 +150,7 @@ private void ShowList(SerializedProperty list)
142150

143151
private static IEnumerable<string> RegisteredKeywords()
144152
{
145-
if (!MixedRealityManager.ConfirmInitialized() ||
146-
!MixedRealityManager.Instance.ActiveProfile.IsInputSystemEnabled ||
153+
if (!MixedRealityManager.Instance.ActiveProfile.IsInputSystemEnabled ||
147154
!MixedRealityManager.Instance.ActiveProfile.InputSystemProfile.IsSpeechCommandsEnabled ||
148155
MixedRealityManager.Instance.ActiveProfile.InputSystemProfile.SpeechCommandsProfile.SpeechCommands.Length == 0)
149156
{

Assets/MixedRealityToolkit-SDK/Inspectors/MixedRealityToolkit.SDK.Inspectors.asmdef

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"references": [
44
"Microsoft.MixedReality.Toolkit",
55
"Microsoft.MixedReality.Toolkit.InputSystem",
6-
"Microsoft.MixedReality.Toolkit.SDK"
6+
"Microsoft.MixedReality.Toolkit.SDK",
7+
"Microsoft.MixedReality.Toolkit.Core.Inspectors"
78
],
89
"optionalUnityReferences": [],
910
"includePlatforms": [

Assets/MixedRealityToolkit/_Core/Inspectors/Profiles/MixedRealityBaseConfigurationProfileInspector.cs

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

44
using Microsoft.MixedReality.Toolkit.Core.Extensions.EditorClassExtensions;
5-
using Microsoft.MixedReality.Toolkit.Core.Managers;
65
using UnityEditor;
76
using UnityEngine;
87

98
namespace Microsoft.MixedReality.Toolkit.Core.Inspectors.Profiles
109
{
11-
public abstract class MixedRealityBaseConfigurationProfileInspector : Editor
10+
public abstract class MixedRealityBaseConfigurationProfileInspector : BaseMixedRealityInspector
1211
{
1312
private static readonly GUIContent NewProfileContent = new GUIContent("+", "Create New Profile");
1413

@@ -44,41 +43,6 @@ protected void RenderMixedRealityToolkitLogo()
4443
GUILayout.Space(12f);
4544
}
4645

47-
/// <summary>
48-
/// Check and make sure we have a Mixed Reality Manager and an active profile.
49-
/// </summary>
50-
/// <returns>True if the Mixed Reality Manager is properly initialized.</returns>
51-
protected bool CheckMixedRealityManager(bool showHelpBox = true)
52-
{
53-
if (!MixedRealityManager.IsInitialized)
54-
{
55-
// Search the scene for one, in case we've just hot reloaded the assembly.
56-
var managerSearch = FindObjectsOfType<MixedRealityManager>();
57-
58-
if (managerSearch.Length == 0)
59-
{
60-
if (showHelpBox)
61-
{
62-
EditorGUILayout.HelpBox("No Mixed Reality Manager found in scene.", MessageType.Error);
63-
}
64-
return false;
65-
}
66-
67-
MixedRealityManager.ConfirmInitialized();
68-
}
69-
70-
if (!MixedRealityManager.HasActiveProfile)
71-
{
72-
if (showHelpBox)
73-
{
74-
EditorGUILayout.HelpBox("No Active Profile set on the Mixed Reality Manager.", MessageType.Error);
75-
}
76-
return false;
77-
}
78-
79-
return true;
80-
}
81-
8246
protected static bool RenderProfile(SerializedProperty property)
8347
{
8448
bool changed = false;

0 commit comments

Comments
 (0)