@tool class_name TextureRectButton extends BaseDataControl @export var icon = Texture: set(value): icon = value self.texture = icon @export var hover_icon = Texture @export var click_icon = Texture @export var is_lock = false @export var is_prompt = false @export var is_click_emit = false @export var waiting_time = 0.2 var prompt = null enum { NIL, CLICK, HOVER } var state = NIL: set(value): state = value match state: NIL: self.texture = icon CLICK: self.texture = click_icon HOVER: self.texture = hover_icon func _ready(): if icon != null: state = NIL mouse_entered.connect(Callable(self,"_on_mouse_entered")) mouse_exited.connect(Callable(self,"_on_mouse_exited")) func click(): if state == CLICK: state = NIL else: state = CLICK if !is_lock: await get_tree().create_timer(waiting_time).timeout if Vec2.has_post(global_position,global_position+size,get_global_mouse_position()): state = HOVER else: state = NIL if is_click_emit: emit_signal("on_click",self) pass func _on_mouse_entered(): if hover_icon != null: if is_lock and state == CLICK: pass else: state = HOVER if is_prompt and tooltip_text != "": if prompt == null : prompt = preload("res://common/gui/tooltip_text.tscn").instantiate() Ui.control.add_child(prompt) prompt.global_position = global_position - prompt.size prompt.text = tooltip_text else: prompt.text = tooltip_text #$Label.visible = true pass # Replace with function body. func _on_mouse_exited(): if icon != null: if is_lock and state == CLICK: pass else: state = NIL #$Label.visible = false if prompt != null: prompt.queue_free() prompt = null pass # Replace with function body.