File tree Expand file tree Collapse file tree 5 files changed +20
-45
lines changed
MixedRealityToolkit-SDK/Inspectors
MixedRealityToolkit/_Core/Inspectors/Profiles Expand file tree Collapse file tree 5 files changed +20
-45
lines changed Original file line number Diff line number Diff line change 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 ;
45using Microsoft . MixedReality . Toolkit . Core . Managers ;
56using UnityEditor ;
67
78namespace Microsoft . MixedReality . Toolkit . SDK . Inspectors . Input . Handlers
89{
9- public class BaseInputHandlerInspector : Editor
10+ public class BaseInputHandlerInspector : BaseMixedRealityInspector
1011 {
1112 private SerializedProperty isFocusRequiredProperty ;
1213
Original file line number Diff line number Diff line change 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 ;
54using Microsoft . MixedReality . Toolkit . SDK . Input . Handlers ;
65using 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 ) ;
Original file line number Diff line number Diff 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 {
Original file line number Diff line number Diff line change 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": [
Original file line number Diff line number Diff line change 22// Licensed under the MIT License. See LICENSE in the project root for license information.
33
44using Microsoft . MixedReality . Toolkit . Core . Extensions . EditorClassExtensions ;
5- using Microsoft . MixedReality . Toolkit . Core . Managers ;
65using UnityEditor ;
76using UnityEngine ;
87
98namespace 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 ;
You can’t perform that action at this time.
0 commit comments