How do you override changing node properties in tool mode?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By avencherus
:warning: Old Version Published before Godot 3 was released.

I was trying to prevent the change of certain properties of a node in tool mode, and most things I’ve tried haven’t resulted in anything.

Right now I’m trying

func _set(property, value):

	if(property == "transform/pos"):
		set(property, Vector2(0, 0))

However this crashes Godot. -_-

Is there a more straightforward way that I’m overlooking?

:bust_in_silhouette: Reply From: Zylann

You can use setget to make variables behave like properties: Is there a way to tell if a tool script's exported variables get updated? - Archive - Godot Forum

How would I do that on built in properties such as a node transform? I’m not sure what that looks like.

avencherus | 2016-10-11 05:11

I believe you can use the _notification function and get something like NOTIFICATION_TRANSFORM_CHANGED or NOTIFICATION_LOCAL_TRANSFORM_CHANGED for Spatial and CanvasItem.

Spatial also has a set_notify_local_transform but is not documented its use.

eons | 2016-10-11 17:38

Thanks. I tried that out this morning and it wasn’t quite working, going back to it to double check though, it seems to be recognizing the notifications properly.

It works now. The one thing to add though is there needs to be a flag involved, or you can trap yourself in non-stop notification loop. As the transform itself will fire off another transformation notification.

avencherus | 2016-10-11 18:17