Skip to content

Commit 0d5c0ff

Browse files
Merge pull request #2387 from StephenHodgson/vNEXT-ControllerFixes
Fixed errors when stopping editor playmode.
2 parents 7057006 + b61eca8 commit 0d5c0ff

File tree

3 files changed

+23
-16
lines changed

3 files changed

+23
-16
lines changed

Assets/MixedRealityToolkit/InputSystem/Focus/FocusProvider.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,8 @@ public uint GenerateNewPointerId()
390390
/// <returns>The UIRaycastCamera</returns>
391391
private void CreateUiRaycastCamera()
392392
{
393+
if (!enabled) { return; }
394+
393395
var cameraObject = new GameObject { name = "UIRaycastCamera" };
394396
cameraObject.transform.parent = transform;
395397
cameraObject.transform.localPosition = Vector3.zero;

Assets/MixedRealityToolkit/InputSystem/MixedRealityInputManager.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ private void InitializeInternal()
102102
{
103103
if (Application.isEditor)
104104
{
105-
#if UNITY_EDITOR
106105
bool addedComponents = false;
107106
var eventSystems = UnityEngine.Object.FindObjectsOfType<EventSystem>();
108107
var standaloneInputModules = UnityEngine.Object.FindObjectsOfType<StandaloneInputModule>();
@@ -121,6 +120,7 @@ private void InitializeInternal()
121120
addedComponents = true;
122121
}
123122

123+
#if UNITY_EDITOR
124124
if (addedComponents) { UnityEditor.EditorGUIUtility.PingObject(FocusProvider.UIRaycastCamera); }
125125
#endif
126126
}
@@ -166,22 +166,22 @@ public override void Destroy()
166166
{
167167
InputDisabled?.Invoke();
168168

169-
if (FocusProvider.UIRaycastCamera != null)
170-
{
171-
if (Application.isEditor)
172-
{
173-
UnityEngine.Object.DestroyImmediate(FocusProvider.UIRaycastCamera.gameObject);
174-
}
175-
else
176-
{
177-
UnityEngine.Object.Destroy(FocusProvider.UIRaycastCamera.gameObject);
178-
}
179-
}
180-
181169
if (focusProvider != null)
182170
{
183171
focusProvider.enabled = false;
184172

173+
if (FocusProvider.UIRaycastCamera != null)
174+
{
175+
if (Application.isEditor)
176+
{
177+
UnityEngine.Object.DestroyImmediate(FocusProvider.UIRaycastCamera.gameObject);
178+
}
179+
else
180+
{
181+
UnityEngine.Object.Destroy(FocusProvider.UIRaycastCamera.gameObject);
182+
}
183+
}
184+
185185
if (Application.isEditor)
186186
{
187187
UnityEngine.Object.DestroyImmediate(focusProvider);

Assets/MixedRealityToolkit/_Core/Devices/MixedReality/WindowsMixedRealityDeviceManager.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,19 @@ public override IMixedRealityController[] GetActiveControllers()
8282
/// </summary>
8383
/// <param name="interactionSourceState">Source State provided by the SDK</param>
8484
/// <returns>New or Existing Controller Input Source</returns>
85-
private WindowsMixedRealityController GetOrAddController(InteractionSourceState interactionSourceState)
85+
private WindowsMixedRealityController GetOrAddController(InteractionSourceState interactionSourceState, bool updateControllerData = true)
8686
{
8787
//If a device is already registered with the ID provided, just return it.
8888
if (activeControllers.ContainsKey(interactionSourceState.source.id))
8989
{
9090
var controller = activeControllers[interactionSourceState.source.id] as WindowsMixedRealityController;
9191
Debug.Assert(controller != null);
92-
controller.UpdateController(interactionSourceState);
92+
93+
if (updateControllerData)
94+
{
95+
controller.UpdateController(interactionSourceState);
96+
}
97+
9398
return controller;
9499
}
95100

@@ -124,7 +129,7 @@ private WindowsMixedRealityController GetOrAddController(InteractionSourceState
124129
/// <param name="interactionSourceState">Source State provided by the SDK to remove</param>
125130
private void RemoveController(InteractionSourceState interactionSourceState)
126131
{
127-
var controller = GetOrAddController(interactionSourceState);
132+
var controller = GetOrAddController(interactionSourceState, false);
128133
InputSystem?.RaiseSourceLost(controller?.InputSource, controller);
129134
activeControllers.Remove(interactionSourceState.source.id);
130135
}

0 commit comments

Comments
 (0)