From 55fd19810200b193e4b85d1ce3b7c47873ac51a6 Mon Sep 17 00:00:00 2001 From: Amir Alizadeh Date: Sun, 19 Jan 2025 23:55:23 +0330 Subject: [PATCH 1/2] Add raycast-first priority to the `UIEditorGizmo` --- Source/Editor/Gizmo/UIEditorGizmo.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Source/Editor/Gizmo/UIEditorGizmo.cs b/Source/Editor/Gizmo/UIEditorGizmo.cs index aba177b7d..0b8994577 100644 --- a/Source/Editor/Gizmo/UIEditorGizmo.cs +++ b/Source/Editor/Gizmo/UIEditorGizmo.cs @@ -714,16 +714,15 @@ namespace FlaxEditor private bool RayCastControl(ref Float2 location, out Control hit) { -#if false - // Raycast only controls with content (eg. skips transparent panels) - return RayCastChildren(ref location, out hit); -#else - // Find any control under mouse (hierarchical) - hit = GetChildAtRecursive(location); + // First, raycast only controls with content (eg. skips transparent panels) + RayCastChildren(ref location, out hit); + + // If raycast failed, then find any control under mouse (hierarchical) + hit = hit ?? GetChildAtRecursive(location); if (hit is View || hit is CanvasContainer) hit = null; + return hit != null; -#endif } private UIControlNode FindUIControlNode(Control control) From ec11a79f552cf69e7b4038119e681ec8f8392eac Mon Sep 17 00:00:00 2001 From: Amir Alizadeh Date: Sun, 19 Jan 2025 23:55:56 +0330 Subject: [PATCH 2/2] Add raycast support to the `ContainerControl` --- Source/Engine/UI/GUI/ContainerControl.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Source/Engine/UI/GUI/ContainerControl.cs b/Source/Engine/UI/GUI/ContainerControl.cs index 530663761..62373f2f6 100644 --- a/Source/Engine/UI/GUI/ContainerControl.cs +++ b/Source/Engine/UI/GUI/ContainerControl.cs @@ -858,6 +858,14 @@ namespace FlaxEngine.GUI } } + /// + public override bool ContainsPoint(ref Float2 location, bool precise = false) + { + if (precise && this.GetType() == typeof(ContainerControl) && BackgroundColor.A <= 0.0f) // Go through transparency + return false; + return base.ContainsPoint(ref location, precise); + } + /// public override void PerformLayout(bool force = false) {