Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing a Node's type should rename it if the name was equal to the previous type #5462

Open
L4Vo5 opened this issue Sep 20, 2022 · 8 comments

Comments

@L4Vo5
Copy link

L4Vo5 commented Sep 20, 2022

Describe the project you are working on

Trying to build a test scene where a Control node has several icon.png and ColorRects as children. Wait, maybe it should be a Node2D instead...

Describe the problem or limitation you are having in your project

When changing a node's type in the editor, it will not change the node's name. This is sometimes confusing if the node was left with the default name, as you can end up with things like a Control node named Node2D. This often happens, for example, when first starting to build a scene, before the purpose and type of every node in it is clearly defined.

I've never found a situation where I didn't immediately want to rename it manually, which is cumbersome because I have to check the exact spelling of the new type.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

The node whose type is changed should be renamed automatically because I don't care about the old name anymore.
If it has a custom name, it shows I do care about the name, so no change should happen.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

When changing a node's type in the editor, if the name is equal to the name of the previous type, or a variation of it ("Panel2", "Panel3", etc.), rename it according to the new type.

If this enhancement will not be used often, can it be worked around with a few lines of script?

You can manually rename the node.

Is there a reason why this should be core and not an add-on in the asset library?

It's a QOL feature that would improve editor usability, and it's too small of a change to bother installing an add-on just for it

@zinnschlag
Copy link

Nodes may be referenced in scripts by name. If the editor automatically renames nodes it will break scripts and since it happens automatically the problem is more likely to go unnoticed by the developer.

I get where you are coming from, but this will cause more harm than good.

@Zireael07
Copy link

@zinnschlag

If the editor automatically renames nodes it will break scripts and since it happens automatically the problem is more likely to go unnoticed by the developer.

Yep, blocked on #899

@Calinou
Copy link
Member

Calinou commented Sep 20, 2022

There was a pull request for this in the past, but it was rejected: godotengine/godot#28817

However, if refactor tooling is implemented, this proposal could likely be accepted.

@Mickeon
Copy link

Mickeon commented Sep 20, 2022

I've been thinking about this for a really long while but I never felt like making a full-on proposal about it. The way this should work as I see it, and this is a personal opinion that may be agreed upon, that this should NOT be an automatic process, at all. Rather, if the conditions are met, the user should be prompted about it. A window popping up and saying something along the lines of "This Node shares the same name as a core class, would you like to rename it, too?"

@mieldepoche
Copy link

I personally don't like small yes/no popups.

Here is how the bottom of this dialog currently looks (in 4.0):
image

I'd rather this be an in-dialog button or checkbox, maybe

  • as a third change and rename option, or
  • as a rename to "{type}" checkbox next to the change button (that way you can't miss it) checked by default when the node has a core name to start with.

@me2beats
Copy link

Nodes may be referenced in scripts by name. If the editor automatically renames nodes it will break scripts and since it happens automatically the problem is more likely to go unnoticed by the developer.

I get where you are coming from, but this will cause more harm than good.

It simply could be an option in EditorSettings and disabled by default.
I personally will use it. I feel kinda bad if a node is Node2D but named Control

@Calinou
Copy link
Member

Calinou commented Sep 26, 2022

It simply could be an option in EditorSettings and disabled by default.

Settings that are disabled by default have poor discoverability. The feature might as well not exist to 99% of users 🙂

I'd prefer we find a way to make this not annoying, so it can be enabled by default (or better, have no setting at all).

@L4Vo5
Copy link
Author

L4Vo5 commented Oct 13, 2023

A workaround mentioned in #7054: renaming a node to an empty name makes it automatically get its base class' name. Way easier than manually typing out the new name, which is what I was doing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants