浏览代码

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 <[email protected]>
Co-authored-by: Aaron Franke <[email protected]>
Markus Sauermann 9 月之前
父节点
当前提交
6f44371df1
共有 3 个文件被更改,包括 5 次插入2 次删除
  1. 4 0
      viewport/gui_in_3d/gui_3d.gd
  2. 0 1
      viewport/gui_in_3d/gui_panel_3d.tscn
  3. 1 1
      viewport/gui_in_3d/project.godot

+ 4 - 0
viewport/gui_in_3d/gui_3d.gd

@@ -30,9 +30,13 @@ func _process(_delta: float) -> void:
 
 
 func _mouse_entered_area() -> void:
 func _mouse_entered_area() -> void:
 	is_mouse_inside = true
 	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:
 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
 	is_mouse_inside = false
 
 
 
 

+ 0 - 1
viewport/gui_in_3d/gui_panel_3d.tscn

@@ -121,7 +121,6 @@ grow_horizontal = 0
 grow_vertical = 0
 grow_vertical = 0
 item_count = 3
 item_count = 3
 popup/item_0/text = "Item 0"
 popup/item_0/text = "Item 0"
-popup/item_0/id = 0
 popup/item_1/text = "Item 1"
 popup/item_1/text = "Item 1"
 popup/item_1/id = 1
 popup/item_1/id = 1
 popup/item_2/text = "Item 2"
 popup/item_2/text = "Item 2"

+ 1 - 1
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."
 as well as forwarding mouse and keyboard input to the GUI."
 config/tags=PackedStringArray("3d", "demo", "gui", "official")
 config/tags=PackedStringArray("3d", "demo", "gui", "official")
 run/main_scene="res://gui_in_3d.tscn"
 run/main_scene="res://gui_in_3d.tscn"
-config/features=PackedStringArray("4.2")
+config/features=PackedStringArray("4.3")
 config/icon="res://icon.webp"
 config/icon="res://icon.webp"
 
 
 [debug]
 [debug]