diff --git a/Basis/Packages/Basis Framework/Device Management/BasisDeviceManagement.cs b/Basis/Packages/Basis Framework/Device Management/BasisDeviceManagement.cs
index f2569c709..b2f976883 100644
--- a/Basis/Packages/Basis Framework/Device Management/BasisDeviceManagement.cs
+++ b/Basis/Packages/Basis Framework/Device Management/BasisDeviceManagement.cs
@@ -41,7 +41,7 @@ public string DefaultMode()
///
/// checks to see if we are in desktop
/// this being false does not mean its vr.
- ///
+ ///
///
///
public static bool IsUserInDesktop()
@@ -188,6 +188,10 @@ public void SwitchMode(string newMode)
}
CurrentMode = newMode;
+ if (newMode != "Desktop" && newMode != "Exiting")
+ {
+ BasisCursorManagement.UnlockCursorBypassChecks();
+ }
OnBootModeChanged?.Invoke(CurrentMode);
Debug.Log("Loading " + CurrentMode);
@@ -475,4 +479,4 @@ public void LoadAndOrSaveDefaultDeviceConfigs(string directoryPath)
UseAbleDeviceConfigs = deviceDictionary.Values.ToList();
}
}
-}
\ No newline at end of file
+}
diff --git a/Basis/Packages/Basis Framework/Device Management/Devices/BasisCursorManagement.cs b/Basis/Packages/Basis Framework/Device Management/Devices/BasisCursorManagement.cs
index 915face9e..1151fdedf 100644
--- a/Basis/Packages/Basis Framework/Device Management/Devices/BasisCursorManagement.cs
+++ b/Basis/Packages/Basis Framework/Device Management/Devices/BasisCursorManagement.cs
@@ -1,6 +1,7 @@
using UnityEngine;
using System.Collections.Generic;
using System;
+using Basis.Scripts.Device_Management;
public static class BasisCursorManagement
{
@@ -8,6 +9,7 @@ public static class BasisCursorManagement
private static List cursorLockRequests = new List();
// Event that gets triggered whenever the cursor state changes
public static event Action OnCursorStateChange;
+
public static void OverrideableLock(string requestName)
{
Cursor.lockState = CursorLockMode.Locked;
@@ -22,12 +24,15 @@ public static bool IsVisible()
{
return Cursor.visible;
}
+
///
/// Locks the cursor to the center of the screen and hides it.
/// Adds a request to lock the cursor.
///
public static void LockCursor(string requestName)
{
+ if (ShouldIgnoreCursorRequests()) return;
+
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
Debug.Log("Cursor Locked");
@@ -39,6 +44,21 @@ public static void LockCursor(string requestName)
/// Removes a request to lock the cursor.
///
public static void UnlockCursor(string requestName)
+ {
+ if (ShouldIgnoreCursorRequests()) return;
+
+ InternalUnlockCursor();
+ }
+
+ ///
+ /// Unlocks the cursor and makes it visible. Bypasses checks that would have prevented it from being unlocked.
+ ///
+ public static void UnlockCursorBypassChecks()
+ {
+ InternalUnlockCursor();
+ }
+
+ private static void InternalUnlockCursor()
{
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
@@ -52,9 +72,20 @@ public static void UnlockCursor(string requestName)
///
public static void ConfineCursor(string requestName)
{
+ if (ShouldIgnoreCursorRequests()) return;
+
Cursor.lockState = CursorLockMode.Confined;
Cursor.visible = true;
Debug.Log("Cursor Confined");
OnCursorStateChange?.Invoke(CursorLockMode.Confined, true);
}
-}
\ No newline at end of file
+
+ private static bool ShouldIgnoreCursorRequests()
+ {
+ var isUserInVR = !BasisDeviceManagement.IsUserInDesktop();
+
+ // When in VR mode, all cursor lock requests are must be ignored,
+ // so that cursor control is not taken away from other external desktop overlay applications.
+ return isUserInVR;
+ }
+}