is there a way to see rect / orange bounding box while play (F5) the project in the editor ?

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

i wanted to see where the hidden node position while play in the editor

I’m not sure if I understand you correctly: You have a a node, that is hidden, but if you run the game you want to be able to see it’s bounding box nonetheless? Why?

njamster | 2020-06-15 10:06

i want to make sure the node position are correct in it places, before it switch to appear again

something like turn on visible collision shape on the debug

well, this isn’t so important right now, as we already solved why there is 4 pixel excess on the vboxcontainer on the column of control node, turn out it need to use custom constant - separation by 0

ruruarchy | 2020-06-17 04:32

:bust_in_silhouette: Reply From: njamster

I still don’t see why you can’t simply call show() on your node, if you want to find out where it is. Seems like reinventing the wheel to me… Anyways: there is no option for that. But if you really want this, you can write some _draw-code to do it for you.

Because parent-nodes are drawn before their children, you cannot put that code to the parent node though. And because _draw-calls are ignored when the node they belong to isn’t visible, you also cannot attach it to the node in question itself.

So if your tree looks like this:

- Root-Node
  - "Node1" (any Control-Node, this is the hidden one)

You want to add a second child in the end:

- Root-Node
  - "Node1" (any Control-Node, this is the hidden one)
  - "Node2" (any CanvasItem-Node, this is our drawing helper)

And then you can attach the following script to “Node2”:

extends Control

func _draw():
	draw_rect(get_node("../Node1").get_rect(), "#FF0000", false)

If “Node1” is not a Control-node, there won’t be a get_rect()-function and you have to derive the dimensions yourself using the position- and size-properties. “Node2” has to be a CanvasItem or there won’t be a _draw-function to override. If “Node1” is moving during runtime, you have to call the update()-function on “Node2”.