godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.05k stars 65 forks source link

EditorPlugin signal for a requested scene change #9619

Open Swarkin opened 2 weeks ago

Swarkin commented 2 weeks ago

Describe the project you are working on

I am making a plugin that lets multiple people collaborate on a project in real time.

Describe the problem or limitation you are having in your project

I couldn't find an intuitive way of detecting whether the SceneTree's node_added/node_removed signals are caused by the user adding/removing a Node, or because of a scene switch. This is necessary to know in order to properly sync Node creations and deletions to the other connected peers.

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

By adding a signal that emits right before a SceneTree gets modified in any way, I can know which edits are made by the user and which are purely because of the switch to another scene. By using the already existing scene_changed signal, I know when to start syncing changes again, the only missing piece is a signal that emits right before a scene change happens (such as "scene_change_requested").

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

When the user switches to a different scene, Godot will call the scene_change_requested signal before any changes to the SceneTree are done.

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

This is very difficult and involves accessing Godot's internal UI, which is not very addon-friendly. It will also break when addons such as script-tabs are used, as they modify the relevant internal UI by quite a bit.

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

Same as the above reason, and a signal has to be added in core.