I have a wall node which has the following structure:
StaticBody2D
CollisionShape2D
Sprite
I want to export a texture variable so that I can drag different images into the walls when I'm designing my levels. I also want to see these changes in the editor.
It wouldn't be enough to just make the children of the StaticBody2D
editable so that I could drag the images into the texture field of theSprite
node, because I may want to change a bunch of these nodes at once.
Here is my script:
tool
extends StaticBody2D
export(Texture) var asset setget my_func
func my_func():
get_node("Sprite").texture = asset
This doesn't seem to work however. When I drag an image into the asset
field of my nodes, nothing happens. It doesn't even change the text in the field from <null>
.
How can I export a texture variable so that I can change the images in multiple of my nodes at once, and view these changes in the editor?