How do I open a scene by its attached script?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By JulioYagami

I don’t know if there are something like this in the current Godot version, but I think it would help a lot when we open the project and have to search for the scenes.

Not sure to understand… one script can be attached to several scenes…

Antilo | 2019-02-21 12:37

Using the same name for both script and scene is a good deal, by doing this you avoid a lot of confusion.

Alex Pires | 2019-02-21 17:04

I think that’s not possible.

RenenerG | 2019-02-22 06:27

:bust_in_silhouette: Reply From: Zylann

A scene can have no script, and a script can be on multiple scenes. Godot does not have a function to do this, because it’s not an enforced rule. You can somehow “link” a script with a scene by embedding it in the scene, which means it won’t have a .gd file of its own and will be stored inside the scene itself (which has some drawbacks tho, such as harder versionning, no name given and global search).
If some of your .gd scripts are specific to one of your scenes in your project, a good practice is to give them the same name. This way, you can easily access them by quick-opening the scene by its name (Ctrl+Shift+O). The scene will open and its script will be available by clicking on the root node’s script icon.

I mean open a scene in the Godot editor though the script it is attached to. In projects with a several number of scenes and scripts I guess it would be a great feature. It could save a lot of time of looking for that lost scene in the file explorer.

JulioYagami | 2019-05-23 13:34

Maybe it could be done with “Find references in scenes”, which would list all scenes where your script is used?

Zylann | 2019-05-23 17:43

Where is it in the editor?

JulioYagami | 2019-05-25 11:26

It’s nowhere, I was just suggesting that could be a feature request.

Zylann | 2019-05-25 11:57