0 votes

Hi,

I have a plugin which act as a integrated map editor inside of Godot. The idea is that the plugin detect if the edited scene is of a certain type and then activate an interface where I can add new nodes through a custom UI. The new nodes are customs scenes. Both the map and the custom elements are declared as "tools". Unfortunately it does not work as expected, most notably Godot when I add a node I can see them in the TreeView or in the Viewport but Godot does mark the scene as change and therefore I cannot save the change manually. If I save automatically through EditorInterface, the scene is not save exactly as is, nodes are misplaced and when I reload I don't get the same scene.

So my question is simple, what is the correct way to modify a scene through a plugin and tools in order to be able to save it correctly afterward?

Thanks

asked Jun 25, 2019 in Engine by BraindeadBZH (1,020 points)

I'm not sure if that's the trick, but you may commit your changes using the UndoRedo system. Maybe that's why Godot doesn't see your scene as modified?
Also if you create nodes you may set their owner as well so they show up in the tree and get saved.

Yes you are correct, I should have updated the topic, because this is what I did. With UndoRedo I was able to correctly trigger Godot to take the change into account. Unfortunately I'm now facing another roadblock. Indeed, when you instantiate a scene through a tool, you cannot add children to it because there is no way, AFAIK, to flag the instance with "editable children". Or to be more precise, you can add children but they won't be saved.

For that you should set the owner as the root of the edited scene.

Setting the owner works for the currently edit scene but not if the scene you want to edit is a node of the edited scene. Normally to do that you have to check the option "Editable Children" otherwise the modification won't be saved, and this option is not available through script.

Better ask for a feature request then, I'm curious how that is done.

Looks like a different issue, it's a bout the feature being on by default rather than allowing tools to toggle it.

I think it is close enough that if they implement this request, it then could be possible to also toggle the feature through script.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.