Safe Lines with Drag-and-Drop Node Reference Code in GDScript #11458
Dark-Horizons
started this conversation in
Scripting
Replies: 1 comment
-
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Currently, when dragging a node from the scene tree to a script, the generated code uses the following format:
@onready var sound_fx: AudioStreamPlayer = $SoundFX
While this works, it leads to "unsafe line number" warnings. To fix this issue, I manually adjust it to:
@onready var sound_fx := $SoundFX as AudioStreamPlayer
This format avoids the warning and ensures type safety.
However, performing this adjustment manually every time can be tedious.
Is there a solution for this? If not, could it be added as an option in the editor settings?
Beta Was this translation helpful? Give feedback.
All reactions