File tree Expand file tree Collapse file tree 4 files changed +14
-7
lines changed
MixedRealityToolkit-Examples/Demos/Boundary/Scripts
MixedRealityToolkit-SDK/Features Expand file tree Collapse file tree 4 files changed +14
-7
lines changed Original file line number Diff line number Diff line change 77using Microsoft . MixedReality . Toolkit . Core . Managers ;
88using Microsoft . MixedReality . Toolkit . Core . Utilities ;
99using System . Collections . Generic ;
10+ using Microsoft . MixedReality . Toolkit . Core . Utilities . Async ;
1011using UnityEngine ;
1112using UnityEngine . Experimental . XR ;
1213
@@ -68,14 +69,15 @@ private void Update()
6869 }
6970 }
7071
71- private void OnEnable ( )
72+ private async void OnEnable ( )
7273 {
74+ await new WaitUntil ( ( ) => MixedRealityManager . BoundarySystem != null ) ;
7375 MixedRealityManager . BoundarySystem . Register ( gameObject ) ;
7476 }
7577
7678 private void OnDisable ( )
7779 {
78- MixedRealityManager . BoundarySystem . Unregister ( gameObject ) ;
80+ MixedRealityManager . BoundarySystem ? . Unregister ( gameObject ) ;
7981 }
8082
8183 #endregion MonoBehaviour Implementation
Original file line number Diff line number Diff line change 77using Microsoft . MixedReality . Toolkit . Core . Interfaces . InputSystem ;
88using Microsoft . MixedReality . Toolkit . Core . Managers ;
99using Microsoft . MixedReality . Toolkit . Core . Utilities ;
10+ using Microsoft . MixedReality . Toolkit . Core . Utilities . Async ;
1011using Microsoft . MixedReality . Toolkit . Core . Utilities . Physics ;
1112using System ;
1213using System . Collections . Generic ;
@@ -224,7 +225,7 @@ public override int GetHashCode()
224225
225226 #region MonoBehaviour Implementation
226227
227- private void Awake ( )
228+ private async void Awake ( )
228229 {
229230 if ( uiRaycastCamera == null )
230231 {
@@ -233,6 +234,8 @@ private void Awake()
233234 CreateUiRaycastCamera ( ) ;
234235 }
235236
237+ await WaitUntilInputSystemValid ;
238+
236239 foreach ( var inputSource in MixedRealityManager . InputSystem . DetectedInputSources )
237240 {
238241 RegisterPointers ( inputSource ) ;
@@ -241,6 +244,8 @@ private void Awake()
241244
242245 private void Update ( )
243246 {
247+ if ( MixedRealityManager . InputSystem == null ) { return ; }
248+
244249 UpdatePointers ( ) ;
245250 UpdateFocusedObjects ( ) ;
246251 }
Original file line number Diff line number Diff line change @@ -30,8 +30,8 @@ public override void OnBeforeFocusChange(FocusEventData eventData)
3030
3131 if ( eventData . Pointer . IsInteractionEnabled )
3232 {
33- MixedRealityManager . TeleportSystem . RaiseTeleportCanceled ( eventData . Pointer , this ) ;
34- MixedRealityManager . TeleportSystem . RaiseTeleportRequest ( eventData . Pointer , this ) ;
33+ MixedRealityManager . TeleportSystem ? . RaiseTeleportCanceled ( eventData . Pointer , this ) ;
34+ MixedRealityManager . TeleportSystem ? . RaiseTeleportRequest ( eventData . Pointer , this ) ;
3535 }
3636 }
3737 else if ( eventData . OldFocusedObject == gameObject )
@@ -40,7 +40,7 @@ public override void OnBeforeFocusChange(FocusEventData eventData)
4040
4141 if ( eventData . Pointer . IsInteractionEnabled )
4242 {
43- MixedRealityManager . TeleportSystem . RaiseTeleportCanceled ( eventData . Pointer , this ) ;
43+ MixedRealityManager . TeleportSystem ? . RaiseTeleportCanceled ( eventData . Pointer , this ) ;
4444 }
4545 }
4646 }
Original file line number Diff line number Diff line change @@ -165,7 +165,7 @@ public Vector3 GetModifiedPosition(IMixedRealityCursor cursor)
165165 }
166166
167167 FocusDetails focusDetails ;
168- if ( MixedRealityManager . InputSystem . FocusProvider . TryGetFocusDetails ( cursor . Pointer , out focusDetails ) )
168+ if ( MixedRealityManager . InputSystem != null && MixedRealityManager . InputSystem . FocusProvider . TryGetFocusDetails ( cursor . Pointer , out focusDetails ) )
169169 {
170170 // Else, consider the modifiers on the cursor modifier, but don't snap
171171 return focusDetails . Point + HostTransform . TransformVector ( CursorPositionOffset ) ;
You can’t perform that action at this time.
0 commit comments