Godot Version
4.3
Question
So if I’m in a Control node and using the built-in function _get_drag_data, you can change the mouse pointer icon using the built-in function set_drag_preview
#pulls texture to show under the mouse using the built-in function
func _get_drag_data(at_position):
var dragSlot = get_slot_node_at_position(at_position)
if dragSlot.item_name == "empty":
return
#var dragTexture:TextureRect
var dragTexture = dragSlot.duplicate()
set_drag_preview(dragTexture.texture) #$TextureRect)
return dragSlot
Except the above returns the error
“Invalid type in function ‘set_drag_preview’ in base ‘Control (inventory_ui.gd)’. The Object-derived class of argument 1 (AtlasTexture) is not a subclass of the expected argument class.”
Because my game data is either going to be an ImageTexture or an AtlasTexture (as above). TextureRect is a Control node that should work, but I define my TextureRect.texture with either an ImageTexture or an AtlasTexture. Do you see the problem?
Is there any way to convert from a Texture2D node texture to a Control node texture so I can drag the image from my game that I want to drag?