Godot: Provide a way to let Node2Ds emit a signal when moved via editor

Created on 10 Jan 2019  路  2Comments  路  Source: godotengine/godot

Version: Godot 3.1 Beta 1

The "item_rect_changed" signal is emitted when a Sprite (or AnimatedSprite) is moved or resized on the editor. It doesn't trigger when using Node2Ds or any other node that inherits from it, making it impossible to track any movement from them in the editor (via tool scripts) for example, unless you come up with a dirty workaround in _process.

Taking a quick look at the source of node_2d, canvas_item and sprite, I see that Node2D's set_position doesn't really call item_rect_changed, which seems a bit inconsistent as it contains not only the size of a canvasItem, but also its position (I guess that when you move a Sprite on the editor, it updates its offset and it calls item_rect_changed?).

Firs of all I'd like to say that I don't know the implications of such a change and if it's feasible. Plus, I'd be content if there was any other way to achieve that as it's essential to be able to know when an object was moved within the scene to make tools more powerful.

enhancement core

Most helpful comment

Does this also apply to Spatial? Is there or would it be useful for there to be a signal whenever a Spatial's position is changed? Perhaps there should be a signal on Node for just "changed"?

All 2 comments

Yes, it its very frustrating why item_rect_changed gets emitted only when the node is of type Sprite (or AnimatedSprite). If item_rect_changed is a signal of CanvasItem you expect every node inherited from CanvasItem to emit this signal whenever it's size or position is changed.

Does this also apply to Spatial? Is there or would it be useful for there to be a signal whenever a Spatial's position is changed? Perhaps there should be a signal on Node for just "changed"?

Was this page helpful?
0 / 5 - 0 ratings