I am using C# and have added a Texture variable
[Export]
Texture txr
When I drag a texture into the field in the inspector, I want the a Node with a TextureRect to update to show the new texture. Is this possible?
I am using C# and have added a Texture variable
[Export]
Texture txr
When I drag a texture into the field in the inspector, I want the a Node with a TextureRect to update to show the new texture. Is this possible?
It might be possible if you make it a tool
script and use a setget
(or equivalent in C#) function. You would need to manually spawn the TextureRect node and oversee it, but I think it might be doable.
Here’s how I could see it doable in GDScript:
tool
extends Node
# I think the code below would work, not totally sure
export (Texture) var txr setget set_txr
var preview_txr_node : TextureRect = null
func _ready():
if (preview_txr_node == null):
preview_txr_node = TextureRect.new()
preview_txr_node.texture = txr
add_child(preview_txr_node)
func set_txr(new_value):
txr = new_value
if (preview_txr_node == null):
preview_txr_node = TexureRect.new()
preview_txr_node.texture = txr
add_child(preview_txr_node)
else:
preview_txr_node.texture = txr
I’m not sure on the 1:1 conversion to C#, but I think its possible to do something similar.
Thank you. I'll try it!