Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a way to update SceneTreeDock #3785

Open
me2beats opened this issue Jan 11, 2022 · 2 comments
Open

Add a way to update SceneTreeDock #3785

me2beats opened this issue Jan 11, 2022 · 2 comments

Comments

@me2beats
Copy link

me2beats commented Jan 11, 2022

Describe the project you are working on

A plugin (gdscript) that copies signals connections
#3775

Describe the problem or limitation you are having in your project

When I create signals connections using a plugin, the SceneTreeDock connection icon/button isn't updated.
It's updated only when I switch to another scene and then go back or reload the saved scene.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

A method to update SceneTreeDock would solve the problem.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

void EditorInterface.update_scene_tree_dock()

If this enhancement will not be used often, can it be worked around with a few lines of script?

A workaround would be to manually reload the scene (see above).
I also have an idea (from the plugin) to create a new empty scene then switch to it then close it, but this looks very hacky (ugly), and also I can't find an easy way how to close a scene from a plugin.

Upd:
I found a workaround to update node connections buttons (thanks to Zylann
suggested using update_tree()):

	var base = get_editor_interface().get_base_control()

	var scene_tree_dock= base.find_node("Scene", true, false)
	var scene_tree_ed =  find_child_by_class(scene_tree_dock, 'SceneTreeEditor')
	scene_tree_ed.update_tree()

static func find_child_by_class(node:Node, cls:String):
	for child in node.get_children():
		if child.get_class() == cls:
			return child

But I still think a similar method could be added/exposed and documented.

Also there are cases when the node added using a plugin/tool script is not displayed (but displayed when switching scenes).
In this case you can try EditorInterface.edit_node() or select the added node (EditorSelection.add_node())

Is there a reason why this should be core and not an add-on in the asset library?

Should be core to be able to update the SceneTreeDock controls from a plugin without hacks

@rossunger
Copy link

Does property_list_changed_notify() not affect the sceneTreeDock?

@Zylann
Copy link

Zylann commented Mar 29, 2024

I recently found that changing the owner of a node that's already in the scene tree, will not update the scene tree either. That's the case whether the node already has an owner, or no owner. One workaround is to switch to another scene tab and back.
So having a way to tell the scene tree to update would help work around this. But...

I also tried the following:

		Node *temp_node = memnew(Node);
		add_child(temp_node);
		temp_node->set_owner(get_tree()->get_edited_scene_root());
		temp_node->queue_free();

Which does update the scene tree specifically.
Unfortunately, my use case is automatically generated NavigationRegion3D nodes, which I can't preview without them being visible in the scene tree. This is why I change the owner temporarily, to see them in the editor.
When I use that workaround, while they show in the tree, they STILL DONT show their navmesh. I have to click on them to see it. And when I set the owner back to null, the navmesh preview does not go away. I have to tab in and out of the scene for that to update.

Maybe this could be considered a bug and should be fixed, because in my case the owner change occurs within the custom node I'm making, so creating a plugin just to do that is quite tedious, and fixing the scene tree is not enough.

Does property_list_changed_notify() not affect the sceneTreeDock?

If I'm not mistaken, property changes have little to do with the scene tree, because the scene tree doesn't show properties? The documentation doesn't indicate much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants