-
-
Notifications
You must be signed in to change notification settings - Fork 96
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 Node.is_being_edited()
as an equivalent of Engine.is_editor_hint()
for editor plugins
#8216
Comments
A cleaner workaround to detect whether the node is being edited, thanks to @kleonc: if get_tree().edited_scene_root != null && get_tree().edited_scene_root in [self, owner]: If this is deemed robust, it could be added as a helper function to the |
Engine.is_editor_hint()
, but for pluginsNode.is_being_edited()
as an equivalent of Engine.is_editor_hint()
for editor plugins
The method exists, it's just not exposed: |
I did not expect that 😁 It looks functionally equivalent to the above GDScript except it also checks And the name It's guarded by |
If a script uses this method, it will have parse error after export. This applies to all editor plugins, so usually it's not a problem. |
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: