This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+5 votes

is there a way to get the current scene name?

in Engine by (1,488 points)

1 Answer

+5 votes
Best answer
by (703 points)
selected by

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()

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

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...

you can just use .name to get the name of the node

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.