Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | jospic | |
Old Version | Published before Godot 3 was released. |
Hi,
is there a way to get the current scene name?
Thanks.
-J
Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | jospic | |
Old Version | Published before Godot 3 was released. |
Hi,
is there a way to get the current scene name?
Thanks.
-J
Reply From: | Gokudomatic2 |
get_tree().get_current_scene().get_name()
is there any reason that calling this would return null instance? i mean there’s always a scene… yet that’s what im getting.
var context = get_tree().get_current_scene().get_name()
trumpetfish1 | 2018-04-28 03:38
If your node is not in the tree (not a child of anything), then get_tree
will be null and the expression will throw a NullRef error
jarlowrey | 2019-08-07 23:38
Thank you for your comment! But when I try it it doesn’t give me the name of the scene but the name of the node…
jobieadobe | 2022-03-13 02:59
you can just use .name to get the name of the node
get_tree().get_current_scene().name
milkteafloat | 2023-05-27 16:16