[Solved][ Texture Button not showing "Pressed"

Godot Version

4.1.1

Question

Learning how the TextureButton node works, having some issues with it.

All other settings are default.

Script is the following:

extends TextureButton

@onready var bitmapReference = preload("res://Old Assets/Sprites/UI/Crafter/Craft.png")

func _ready():
	var textureBitMap = BitMap.new()
	textureBitMap.create_from_image_alpha(bitmapReference)
	set_click_mask(textureBitMap)

When the Script is Detached, the button successfully emits the Pressed() signal, but doesn’t change into the Pressed texture.

When the Script is Attached, nothing happens and the following error is output.

PictureButton.gd:8 @ _ready(): Condition "p_image.is_null() || p_image->is_empty()" is true.

Any ideas as to why the “Pressed” texture doesn’t appear when the mouse is held down? Also where am I going wrong on the bitmap?

You need to do:

textureBitMap.create_from_image_alpha(bitmapReference.get_image())

The loaded data is a texture

2 Likes

Fantastic, works great!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.