godot
godot copied to clipboard
Assume root when dropping node to unassigned script
When dropping a node to Script Editor, you will sometimes get the arbitrary error that the script is nowhere in the scene:
https://github.com/godotengine/godot/assets/2223172/356f5efb-7211-4350-9bd1-c982041dd5a7
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:
https://github.com/godotengine/godot/assets/2223172/51300850-ba34-4f5b-aebf-c00d0cb3770f
The second video shows that @onready ... can be dropped to a script not extending Node, which doesn't make sense / shouldn't be allowed.
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:
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. :thinking: 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).
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.
https://github.com/godotengine/godot/assets/2223172/0c99b0cc-4ebc-4cce-bfb1-a943c47cf7ec
Thanks!