godotengine / godotengine/godot
The method Node3D.get_gizmos() does not get the gizmo for Node3D class, but only subclass nodes.
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
v4.4.1.stable.official [49a5bc7b6]
### System information
Kubuntu 24.04
### Issue description
Created an EditorPlugin to access the gizmo data of nodes as they are selected. The node is selected, but for the `Node3D` class the `get_gizmo() `method returns an empty array[] (no gizmos). However if the nodes are of class `MeshInstance3D`, `Camera3D`, `StaticBody3D` etc, the gizmos are returned.
The addon code of the plugin is shwon below:
```gdscript
@tool
extends EditorPlugin
func _enter_tree():
# Connect to the selection_changed signal.
EditorInterface.get_selection().connect("selection_changed", Callable(self, "_on_selection_changed"))
func _exit_tree():
# Disconnect the signal when the plugin is removed.
EditorInterface.get_selection().disconnect("selection_changed", Callable(self, "_on_selection_changed"))
func _on_selection_changed():
var selected_nodes:Array[Node] = EditorInterface.get_selection().get_selected_nodes()
# Check if any nodes are selected.
if selected_nodes.size() > 0:
# Get the first selected node.
print("\n\nClass: ", selected_nodes[0].get_class())
#print(get_main_screen())
var gizmos:Array[Node3DGizmo]
for node:Node3D in selected_nodes:
#if node is Node3D:
gizmos = node.get_gizmos()
prints("Node: ",node.name,"Gizmos: ",gizmos)
```
plugin.cfg
```
[plugin]
name="gizmos"
description="Plugin access gizmos."
author="wyattbiker"
version="1.0-BETA"
script="plugin.gd"
```
Sample output when clicking on nodes of various classes:
```
Class: Node3D
Node: Gizmos Gizmos: []
Class: MeshInstance3D
Node: MeshInstance3D Gizmos: [, ]
Class: StaticBody3D
Node: StaticBody3D Gizmos: []
Class: Camera3D
Node: Camera3D Gizmos: [, ]
```
### Steps to reproduce
- Drop the gizmo **plugin.gd** and **plugin.cfg** into an gizmos **addons/ folder** of any godot project.
- Create a scene and add some `Node3D` nodes as well as other `Node3D` class derivatives such as `MeshInstance3D` or `Camera3D` or `StaticBox3D`.
- Enable gizmo plugin.
- Click on nodes and noticed that the output from Node3D>>`get_gizmos()` method does not show gizmos for `Node3D` node, but only for the subclasses.
### Minimal reproduction project (MRP)
[Archive.zip](https://github.com/user-attachments/files/21069080/Archive.zip)
To test:
Copy folder addons/gizmos to project
Copy getgizmos scene to main project folder
Open scene and click on nodes.
Contributor guide
Research direction
Start with the provided plugin.gd and plugin.cfg, then reproduce the behavior using the Archive.zip project and the Node3D.get_gizmos() entry point. Compare the returned gizmos for Node3D and its subclasses in the sample scene. Done means the reported behavior is explained and the appropriate regression coverage or fix is identified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- game-dev, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100