Add Node.is_being_edited()
as an equivalent of Engine.is_editor_hint()
for editor plugins
#8216
Labels
Milestone
Describe the project you are working on
A bespoke editor plugin for my game.
Describe the problem or limitation you are having in your project
Plugin code needs to be marked with
@tool
in order to run in the editor.However, this also causes the code to be run while editing a scene belonging to the plugin. This is often undesirable, because it makes changes to the scene which then get saved in the
.tscn
file.For non-plugin scripts,
Engine.is_editor_hint()
is used to work around this. But in a plugin script, this function always returns true, even while the plugin is running "as a plugin" and is not being edited.Describe the feature / enhancement and how it helps to overcome the problem or limitation
Since the node will be part of the same engine instance and scene tree, whether it's running as a plugin or running in the scene editor, a global function like
Engine.is_editor_hint()
won't be possible.Instead, maybe a function on
Node
could be added, likeis_being_edited()
.Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
is_being_edited()
could look at the node's ancestors to find out whether the node is a descendant of the scene editor. I think that would be theCanvasItemEditor
class in the current implementation, but this is not exposed in the API.If this enhancement will not be used often, can it be worked around with a few lines of script?
Yes, I'm currently using something along these lines as a workaround, but it only works for main screen plugins:
Is there a reason why this should be core and not an add-on in the asset library?
Seems like many plugins that use scenes can benefit from this.
The text was updated successfully, but these errors were encountered: