Using @tool for only certain parts of a script

Godot Version

4.5

Question

I have made a node that allows you to change the texture that a sprite that is a child of that node will use, the only issue is that when you change that property, the change is put in effect in the _ready() function of the script, so you can’t see the change in the editor. I know you can use the @tool annotation to run code in the editor and a setter to change the property, but I don’t want all of the code in the script to run in the editor, just the parts regarding the node’s attributes. Is there any way I can do this?

You can use Engine.is_editor_hint()

func _process(delta: float) -> void:
	if Engine.is_editor_hint():
		# Code to execute in editor.

	if not Engine.is_editor_hint():
		# Code to execute in game.

	# Code to execute both in editor and in game.