Topic was automatically imported from the old Question2Answer platform.
Asked By
Matty101
What i’m trying to accomplish is for the mouse cursor to change to the sprites image when i click that sprite.
what i have so far is:
func on_click():
var dragable_Image = get_node("../Icon_image")
var Image_rect = dragable_Image.get_region_rect()
var new_Icon = dragable_Image.get_texture().get_data().get_rect(Image_rect)
Input.set_custom_mouse_cursor(new_Icon,Input.CURSOR_ARROW,Vector2(8,8))
comes up with: Condition ’ !texture.is_valid() ’ is true.
so i’m guessing i’m miss-handling some data on that 2nd last line and new_icon isn’t getting texture data
Which line did cause the error? (you should be able to check in the bottom panel of the editor)
set_custom_mouse_cursor expects a Texture, not an Image. new_Icon is an image here.
It’s a confusing API, as the argument type is not specific and it says “image” while not handling images properly. Worse, because of this, you got an Image from a Texture, which you will have to re-upload to the graphics card by creating a Texture, for the function to download it again just to get an image and create a bitmap internally for the OS… surreal, isn’t it ^^"
It looks like a bug.