godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.16k stars 97 forks source link

Add an option to mark a node and it's children as editor or debug only #11162

Open funkysandwich opened 1 week ago

funkysandwich commented 1 week ago

Describe the project you are working on

A VR game with grabbable objects.

Describe the problem or limitation you are having in your project

I have a node that marks a 'grab point' on an interactable, and I would like a cleaner way to visualize these in the editor.

How I am doing this currently:

I have a scene with the grab point script on the root, and a meshinstance as a child of that, with the mesh set to a model of a hand. I can toggle a custom 'visible' property on the grab point to set the visibility of this hand. This helps me position the grab points where I want them in the editor easily. image

I want this to only be visible within the editor, regardless of if I left Show Visual on, and to have the node for the visual be removed from builds as it is not needed.

I can remove the node on spawn in builds, but if it's intended for the editor, why spawn it in builds at all? I think there should be a built in way to do this.

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

Editor only nodes would be a clean way to help people quickly create their own helper visuals for the editor. This proposal is asking for something similar, but for 2D sprites. https://github.com/godotengine/godot-proposals/issues/11105 I propose being able to mark a node as being editor or debug only, and this would work for all types of nodes.

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

A new enum property would be added to Node with three options:

The editor would also have a new option under the Debug tab that would allow creating debug nodes, similar to how you can enable collision shape visibility when running from the editor. image The Editor Only option of this enum for all nodes would also replace the Editor Only checkbox for lights. image

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

Yes.

extends Node

func _ready() -> void:
    if not OS.get_cmdline_args().has("--debug-nodes"):
        print('Removing debug node %s' % get_path())
        queue_free()

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

A built in option to mark a node as an editor or debug node would be a convenient feature.

Calinou commented 1 week ago