+2 votes

I created a level object as a scene, and I need to display special things in the editor to make its edition more user-friendly.
I tried to add it in the script with get_tree().is_editor_hint(), but because of the way my script works it becomes a bloat nightmare.

So I'm doing this with additional nodes, so the two logics are well separated. While these nodes are handy, I don't want them to end up in the exported game.

How can I tell Godot not to include a specific node of a scene?

in Engine by (27,962 points)

3 Answers

+2 votes

On Godot 2.1 you can make an EditorExportPlugin to pick the scene, remove the node you don't want, re-pack the scene (with PackedScene.pack()) and return it with var2bytes().

It's a convoluted process, but for such a specific situation I think there's no easy way.

by (801 points)
0 votes

I would suggest simply remove with free or queue_free node in ready if get_tree().is_editor_hint()check fails.

by (1,285 points)

I thought about this solution as well. Should be ok for a small amount of nodes but I would prefer a scalable solution.
Actually, I managed to modify my script so I can integrate the editor code with reasonable overhead without relying on additional nodes. Well, it doubles the script's size and there are extra calls in a few setters and _process(), but I don't have any better solution yet.

0 votes

The first thing I'd do is put all your editor-only nodes into one group; that should make it easier to act on them (via get_nodes_in_group or similar). Then have one central script in charge of managing that group - maybe when the scene runs it checks for whether it's in the editor or not, and frees all the nodes in that group if it isn't.

by (334 points)
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.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.