Dont unfocus game window while cursor is not visible unless the lock mode is none.

This commit is contained in:
Chandler Cox
2024-05-04 17:37:32 -05:00
parent 9d830eb1e2
commit 430b22d5d7

View File

@@ -470,6 +470,10 @@ namespace FlaxEditor.Windows
IsMaximized = false;
IsBorderless = false;
Cursor = CursorType.Default;
Screen.CursorLock = CursorLockMode.None;
if (Screen.MainWindow.IsMouseTracking)
Screen.MainWindow.EndTrackingMouse();
RootControl.GameRoot.EndMouseCapture();
}
/// <inheritdoc />
@@ -478,7 +482,7 @@ namespace FlaxEditor.Windows
base.OnMouseLeave();
// Remove focus from game window when mouse moves out and the cursor is hidden during game
if ((IsFocused || ContainsFocus) && Parent != null && Editor.IsPlayMode && !Screen.CursorVisible)
if (ContainsFocus && Parent != null && Editor.IsPlayMode && !Screen.CursorVisible && Screen.CursorLock == CursorLockMode.None)
{
Parent.Focus();
}