Behaviour in editor of custom controls that use sub nodes

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By AndyAstrand

So I have a pretty complex custom control I want to use.

It has a textured frame, a textured interior, a variety of fx that can be applied to the texture interior, and effects on the frame, plus overlays to indicate various ready states.

I was planning to do it all in the draw, but the need to have a way of making the interior texture greyscale, and the necessity of doing that with a shader made me realize that all of the things done in _draw are affected by the set material at the end, e.g. I can’t draw that bit of the control in color, then draw the insides in greyscale by using a shader material because it just all comes out in grey.

So going back to how I would have done this originally is by the control creating sub-controls, in this case Sprite2Ds. These I create in the _ready(), then I scale and position them, I respond to resized() events. Everything seems fine, I get a single node in the Scene node list.

Then I save and load the project, or the scene, or I copy/cut and paste the control. Now not only the parent control node is visible but the sub-nodes are also visible in the viewer, and are selectable, and cover the area of whole control. Meaning that it’s a complete nightmare to deal with. You casually try and move the control to another location and you pick the second on the sub nodes and move it a mile away and leave the button frame behind.

Is there a way of preventing this? Is there a node name prefix that stops the controls appearing, or a top level control flag to say don’t show child nodes in the editor, or something. I’ve gone through the somewhat sparse docs on custom controls and can’t find anything.

enter image description here

:bust_in_silhouette: Reply From: AndyAstrand

Answering my own question when I went looking for a manual solution.

Thanks to: This Answer Over Here

I can set the meta information on the sub nodes when I create them

	var frame_node = self.get_node("_frame_node")

if frame_node == null:
	frame_node = = "_frame_node"
	frame_node.set_meta("_edit_lock_", true)

They still appear in the node list in the editor but now at least I can’t select them by accident.