From 6f44371df10adfac0c0daf9ef0fb3ba870171924 Mon Sep 17 00:00:00 2001 From: Markus Sauermann <6299227+Sauermann@users.noreply.github.com> Date: Mon, 25 Nov 2024 18:38:26 +0100 Subject: [PATCH] Fix physics picking in Gui in 3D Demo (#1139) Physics picking requires that the SubViewport has a consistent state of the mouse-enter/exit notifications. Godot V4.3 was changed in comparison to V4.2, so that it now requires this additional step. Co-authored-by: Hugo Locurcio Co-authored-by: Aaron Franke --- viewport/gui_in_3d/gui_3d.gd | 4 ++++ viewport/gui_in_3d/gui_panel_3d.tscn | 1 - viewport/gui_in_3d/project.godot | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/viewport/gui_in_3d/gui_3d.gd b/viewport/gui_in_3d/gui_3d.gd index c98de9d9..ab66f36d 100644 --- a/viewport/gui_in_3d/gui_3d.gd +++ b/viewport/gui_in_3d/gui_3d.gd @@ -30,9 +30,13 @@ func _process(_delta: float) -> void: func _mouse_entered_area() -> void: is_mouse_inside = true + # Notify the viewport that the mouse is now hovering it. + node_viewport.notification(NOTIFICATION_VP_MOUSE_ENTER) func _mouse_exited_area() -> void: + # Notify the viewport that the mouse is no longer hovering it. + node_viewport.notification(NOTIFICATION_VP_MOUSE_EXIT) is_mouse_inside = false diff --git a/viewport/gui_in_3d/gui_panel_3d.tscn b/viewport/gui_in_3d/gui_panel_3d.tscn index f1402e24..2600b28c 100644 --- a/viewport/gui_in_3d/gui_panel_3d.tscn +++ b/viewport/gui_in_3d/gui_panel_3d.tscn @@ -121,7 +121,6 @@ grow_horizontal = 0 grow_vertical = 0 item_count = 3 popup/item_0/text = "Item 0" -popup/item_0/id = 0 popup/item_1/text = "Item 1" popup/item_1/id = 1 popup/item_2/text = "Item 2" diff --git a/viewport/gui_in_3d/project.godot b/viewport/gui_in_3d/project.godot index e90d4662..9b7a07a0 100644 --- a/viewport/gui_in_3d/project.godot +++ b/viewport/gui_in_3d/project.godot @@ -15,7 +15,7 @@ config/description="A demo showing a GUI instanced within a 3D scene using viewp as well as forwarding mouse and keyboard input to the GUI." config/tags=PackedStringArray("3d", "demo", "gui", "official") run/main_scene="res://gui_in_3d.tscn" -config/features=PackedStringArray("4.2") +config/features=PackedStringArray("4.3") config/icon="res://icon.webp" [debug]