godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
89.22k stars 20.22k forks source link

Cannot rename Node in a scene #27293

Closed Cevantime closed 4 years ago

Cevantime commented 5 years ago

Godot version: 3.1 Official

Issue description: In one of my project, I have a scene (just one scene) where I cannot rename any of the children Node by double clicking the name of the Node or by right clicking and select Rename menu item. Selecting Rename menu item gives me the ability to edit the name but the change won't take effect (after pressing Enter, the name remains unchanged) What is expected (obviously) is that I can rename all the node that are not packed in a subscene in the current scene.

Steps to reproduce: Unfortunately, I've no idea of what provoked this issue and how to reproduce it. To see this bug in action, just grab the project linked below. Please note that this problem also occurs when I try to open the 3.0 version of this project

Minimal reproduction project: It's worth noting that the only scene where the problem occurs is the main scene (Level.Tscn) FurryBirds.zip

EDIT: Okay, I figured out what the problem comes from : One of the child is in tool mode and draws a trajectory by adding children to the scene. This somehow has to do something with this renaming issue. Deactivating trajectory drawing solves the problem. But still I would not say there is no issue here.

henkz1 commented 5 years ago

The problem is not that it is a tool script, but probably because the tool script is adding and removing nodes to the tree every frame. This is also causing high cpu usage and scene tree editor is slow to respond to input. I'd say it's still a bug though. You should probably find a way to draw the trajectory without adding/removing nodes, and/or only do it when there is a change in trajectory.

Cevantime commented 5 years ago

Thanks for the answer. All the options you propose are correct and I managed to solve my problem. I do agree with you, there is actually a bug here and it is probably linked with removing/adding children (intensive cpu usage cannot explain this behaviour since the editor is still responding quite fast to anything else).

henkz1 commented 5 years ago

Yea the issue is definitely the constant adding/removing of nodes, the cpu usage is just a reason not to do it.

KoBeWi commented 4 years ago

This is not a bug. Adding and removing nodes will refresh the scene tree, which makes the double-click impossible (because refresh happens between clicks) and cancels the renaming. You can see what happens if you add spot.owner = self under $Trajectory.add_child(spot).

Maybe engine could handle it better, e.g. by not refreshing scene tree on nodes that the scene doesn't own (and thus they are invisible in the tree), but IMO it's not worth it. It's incorrect tool script usage. Even if the "bug" was fixed, removing and adding many nodes each frame is still a bad idea.