How can I create nodes with fields editable in the 2D Editor Panel?

Godot Version

4.3.beta2

Question

I want to make a node where the exported properties are also editable in the 2D Editor Window. An example of how I want this to work are control nodes. You can edit the anchors in the inspector, but you can also drag the points around in the 2D window. Same with a RectangleShape2D, where dragging on any of the points changes the underlying rect.

I tried creating a tool script of a Node which would add Marker2Ds as children. Then dragging around the Marker2Ds could update the tool Node, but since I don’t set the owner on the Marker2Ds, they aren’t even rendered. (I don’t want to set the owner on the Marker2Ds; I don’t want them to persist to the running game)

How do built-in nodes like Controls and CollisionShape2Ds add these editable points?

You can have the tool script check if it is editor or in game.

Then you can hide / disable them when in game and re-enable them in editor.

if Engine.is_editor_hint():