Godot: Double-clicking a script file to open it brings up the Script view, but doing the same for a scene doesn't bring up the 2D/3D view

Created on 17 Apr 2017  路  13Comments  路  Source: godotengine/godot

At least, this is true on Godot 2.1.3.

enhancement junior job editor usability

Most helpful comment

The script editor shows scripts for different scenes in one window, so I don't see why it shouldn't switch?

All 13 comments

It works for me on win10 2.1.3 build

This is with the scene/script already open (just with a different view currently selected). It might behave differently if they aren't.

For me, it works even if they are already open.

Hmm. Well, for me in Godot 2.1.3 on macOS Sierra, double-clicking my .gd file (which is already open) will switch to the Script view, but double-clicking my .scn file (which is also already open) will not switch to the 3D view.

Oh yeah, I got it now! When you are _in the script editor_ and double click on a scene, it doesn't switch. Previously I only tried from the scene view.

It's the same in 3.0

It is not a bug for sure, and I don't think it should be changed. If the scene root has a script it opens that up, so the editor does open the scene.

It happens even if the scene root has no script attached to it.
So it should be fixed IMO, since it's super annoying when you are in script mode and want to open other scene but you have to switch to scene mode first.

Godot 2.1.4.beta.official and 3.0.alpha on macOS Sierra

The script editor shows scripts for different scenes in one window, so I don't see why it shouldn't switch?

Still reproducible in the current master branch, should be easy to make it that a double click on a scene file would focus the relevant viewport editor plugin.

I'll look into it if someone gives me a hint to which files should i look

I looked into this issue and it doesn't seem as simple, because of how editor selection is handled as well as what the spec is. I'd like to check if my assumptions are correct, get more clarity on the spec as well as how much should be changed before I make a PR.

Editor switching is done through EditorNode::_editor_select(), so I thought it was a matter of calling this function after EditorNode::open_request() (called by the filesystem dock when a scene file is double clicked on), but _editor_select() returns early if there's a scene change, presumably because some other actions need to be taken before the view can change.

https://github.com/godotengine/godot/blob/ab8f3d7842976b7fccc6df7abe11d13b44a134f9/editor/editor_node.cpp#L2444-L2448

Thus, _editor_select() is actually triggered by the deferred function EditorNode::_set_main_scene_state(), after it resets the changing_scene flag. There's also a convenient heuristic there, choosing between 2D/3D view depending on the edited scene.
https://github.com/godotengine/godot/blob/ab8f3d7842976b7fccc6df7abe11d13b44a134f9/editor/editor_node.cpp#L2750-L2761
It looks like prioritizing the Script Editor is intentional though, but removing that prioritization would be a simple way to solve this issue for most cases. What was the rationale behind prioritizing the Script view?
https://github.com/godotengine/godot/blob/ab8f3d7842976b7fccc6df7abe11d13b44a134f9/editor/editor_node.cpp#L2743

One way I thought of solving this without changing how things work currently, is to pass a flag indicating that this scene change was triggered by the filesystem dock, and propagate through open_request(), load_scene(), set_current_scene(), and finally _set_main_scene_state(). That seems clunky to me, but what do the more experienced contributors think?

Another question I have is how to handle cases where scene_a is the active scene tab, the editor is in script view, and scene_a.tsgn is double clicked in the file explorer. Currently, Godot, through EditorNode::_scene_tab_changed(), tries to change the scene to scene_a, but because scene_a is already the active tab it does nothing.
https://github.com/godotengine/godot/blob/ab8f3d7842976b7fccc6df7abe11d13b44a134f9/editor/editor_node.cpp#L4079-L4080
I think in this case we should expect to switch to the 2D/3D view of scene_a, and we can do that by manually calling _editor_select() there (that means _scene_tab_changed() needs a flag too, if that method is chosen.)

Does it need to be improved tho? It already opens the related viewport, but if you are in script editor, it opens the dominant script. It's fine IMO.

Was this page helpful?
0 / 5 - 0 ratings