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

EditorPlugin.make_visible() is called multiple times when already visible and selecting another object the plugin handles #40166

Open
Zylann opened this issue Jul 6, 2020 · 3 comments

Comments

@Zylann
Copy link
Contributor

Zylann commented Jul 6, 2020

Godot 3.2.2
Windows 10 64 bits

As a continuation of #6459 (comment)

I made a plugin which can edit a specific object with a graph editor. Selecting that object shows it (throught make_visible), and clicking on a GraphNode may allow to inspect properties of a sub-object using the inspector, similar to how VisualScript works. I made it so my plugin handles both object types, so my expectation was that it would not be made invisible when I select back and forth between these objects.

The problem is, when I use inspect(), Godot calls make_visible() on my plugin 4 times in a row, with alternating visibilities. Not only this is a waste as I cleanup my UI when my plugin is hidden, but even if I don't cleanup anything, hiding the GraphEdit breaks its input management, causing nodes to stick to the mouse, box selections to never end or to never be shown. It's basically unusable.
I would have expected make_visible() to not be called at all, because I edited another sub-object my plugin also handles.

Repro:
PluginInspectMakeVisible.zip
Here I chose Sprite and GraphNode for the sake of testing, in reality my objects are different.

Called make_visible True (1)
Called make_visible False (2)
Called make_visible True (3)

4 additional prints from the present issue, due to selecting the second handled object:

Called make_visible False (4)
Called make_visible True (5)
Called make_visible False (6)
Called make_visible True (7)

I expected just one in total, make_visible(true).

@nonfinity
Copy link

Godot Version: 3.3.rc8.official
Windows 10 64bit

I believe I'm hitting this same bug when using a Main Screen Plugin.
inspect_object() seems to be triggering make_visible calls when then lead to the GraphNode getting "stuck" to the mouse.

plugin_test_01.zip

@and3rson
Copy link
Contributor

and3rson commented Aug 12, 2022

I can also reproduce this under exact same circumstances. Godot v3.5 stable. GraphNode simply sticks to the mouse.

Is there any way to prevent Godot from calling make_visible(false) when we need to inspect some sub-resource that our plugin uses?

EDIT: Just found the solution! Turns out the 3rd arg of get_editor_interface().inspect_object is exactly for this. Pass true in there to prevent Godot from treating the inspected resource as a subject for plugins. E.g.:

get_editor_interface().inspect_object(obj, '', true)

Using this, make_visible is not called and there's no need to handle multiple object types in handles().

@Zylann
Copy link
Contributor Author

Zylann commented Feb 21, 2023

Unfortunately inspect_object(obj, '', true) now calls edit(null) and make_visible(false) when I try it...

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

5 participants