-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Create onready variables when dropping nodes and holding Ctrl #60708
Conversation
Any chance it could add also a type hint when they are enabled in editor settings? Also do you handle name conflicts automatically? It's possible to have two same-named nodes at different branches. |
It's included. See 0:18 in the video. @onready var animation_player := $AnimationPlayer as AnimationPlayer
No, it's always the snake_cased node name. I think it's easier to let the user decide the name in this case. It's hard to find a strategy that satisfies everyone. In the end, it's usually those parts other than the variable name that are quite repetitive and annoying. |
Ah, I didn't watch it whole, sorry.
Makes sense. |
|
for (const String &segment : path.split("/")) { | ||
if (!segment.is_valid_identifier()) { | ||
path = path.c_escape().quote(quote_style); | ||
break; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part is great. If you copied it below, you could also solve #33317
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that is worth a dedicated PR. It changes the meaning of normal node dropping from inserting a string containing the node's path to inserting the path after $
.
Thanks! |
This expands uppon godotengine#60708, using `get_node("%NodeName")` for nodes that have a unique scene name to avoid having to change the onready statements when the paths of the nodes change.
This expands uppon godotengine#60708, using `get_node("%NodeName")` for nodes that have a unique scene name to avoid having to change the onready statements when the paths of the nodes change. (cherry picked from commit 1101f6c)
any way to make this work on MacOS? holding ctrl acts as a right click. |
This expands uppon godotengine#60708, using `get_node("%NodeName")` for nodes that have a unique scene name to avoid having to change the onready statements when the paths of the nodes change. (cherry picked from commit 1101f6c)
@hamoom For MacOS you can drag from Scene to Script with left click. But before you drop, hold down |
For mac users of the future(compared to this thread), you must |
Like Ctrl drop files adds
preload
to the path, this PR makes Ctrl drop nodes inserts onready variable code.Peek.2022-05-02.21-03.mp4
Proof of concept and closes godotengine/godot-proposals#4482