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

Assume root when dropping node to unassigned script #79258

Merged
merged 1 commit into from
Aug 1, 2023

Conversation

KoBeWi
Copy link
Member

@KoBeWi KoBeWi commented Jul 9, 2023

When dropping a node to Script Editor, you will sometimes get the arbitrary error that the script is nowhere in the scene:

godot.windows.editor.dev.x86_64_OKhG6zXBp7.mp4

The error may appear in valid scenarios, e.g. when dropping node into parent script. In any case, I think it's less relevant now that we have scene unique names, as the hierarchy does not matter that much.

With this PR, if a script is not found in the scene, the editor will assume that the node is relative to scene's root (which, again, is irrelevant if the node has unique name). Here's me casually dropping a node into random EditorScript:

godot.windows.editor.dev.x86_64_oyd0AnwWoF.mp4

@KoBeWi KoBeWi added this to the 4.x milestone Jul 9, 2023
@KoBeWi KoBeWi requested a review from a team as a code owner July 9, 2023 21:24
@kleonc
Copy link
Member

kleonc commented Jul 10, 2023

The second video shows that @onready ... can be dropped to a script not extending Node, which doesn't make sense / shouldn't be allowed.

@KoBeWi
Copy link
Member Author

KoBeWi commented Jul 10, 2023

tbh dropping nodes to scripts that don't inherit Node does not make sense, because they don't have get_node() xd
I added a new warning:
image

@kleonc
Copy link
Member

kleonc commented Jul 10, 2023

tbh dropping nodes to scripts that don't inherit Node does not make sense, because they don't have get_node() xd

It could be argued that dropping just the NodePath (drop without Ctrl pressed) should be allowed though. 🤔 I mean Node-deriving is needed only if get_node/@onready is used. There's nothing wrong with having a NodePath in e.g. a Resource (even if that's not recommended).

@KoBeWi
Copy link
Member Author

KoBeWi commented Jul 10, 2023

idk, I think I never needed node paths in resources. It could be easily implemented if someone wants it, but for now I'd stay with nodes only.

Copy link
Member

@kleonc kleonc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

As mentioned, dropping NodePaths to non-Nodes could be allowed later if/when requested (in the meantime NodePaths can be copied manually from the scene tree dock anyway).

@YuriSizov YuriSizov modified the milestones: 4.x, 4.2 Jul 25, 2023
@KoBeWi
Copy link
Member Author

KoBeWi commented Aug 1, 2023

godot.windows.editor.dev.x86_64_ZIN4VSbHhF.mp4

@YuriSizov YuriSizov merged commit de0a06e into godotengine:master Aug 1, 2023
13 checks passed
@YuriSizov
Copy link
Contributor

Thanks!

@KoBeWi KoBeWi deleted the drag_and_drop_anarchy branch August 1, 2023 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants