I believe, though I have not double checked, that Transform.scale
is defined in Node2D
and RectScale
is defined in Control
. This should make it where you can determine which property to modify just by checking if the node extends Node2D or Control, making it where there only has to be two conditionals to handle all of the CanvasItem extending Godot nodes. Something like this (untested, GDScript):
if (node is Control):
node.rect_scale = Vector2(1, 1)
elif (node is Node2D):
node.transform.scale = Vector2(1, 1)
Though this method does require you to check the type of the generic type passed-in to the function, unfortunately.
I'm not sure if there is a universal scale property. I'd look at the documentation for CanvasItem and see if there is anything defined there that would help, since both Node2D and Control nodes extend CanvasItem.