From 34346e411122389676d727f4f2a955ccad1ef9da Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Sun, 1 Dec 2024 21:47:54 +0200 Subject: [PATCH] Force cursor to center of Game Window when tab handle is clicked --- Source/Editor/Windows/GameWindow.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/Editor/Windows/GameWindow.cs b/Source/Editor/Windows/GameWindow.cs index 0366cef8f..653ff1d0c 100644 --- a/Source/Editor/Windows/GameWindow.cs +++ b/Source/Editor/Windows/GameWindow.cs @@ -1068,8 +1068,11 @@ namespace FlaxEditor.Windows if (Editor.StateMachine.IsPlayMode && !Editor.StateMachine.PlayingState.IsPaused) { + // Make sure the cursor is always in the viewport when cursor is locked + bool forceCenter = _cursorLockMode != CursorLockMode.None && !IsMouseOver; + // Center mouse in play mode - if (CenterMouseOnFocus) + if (CenterMouseOnFocus || forceCenter) { var center = PointToWindow(Size * 0.5f); Root.MousePosition = center;