I have a shader:
shader_type canvas_item;
uniform float progress: hint_range(0.0, 1.0) = 0.0;
void fragment() {
COLOR.a = step(UV.x, progress);
}
that is supposed to reveal an image via a tween when a button is pressed. Hence, I am controlling the shader via this code: (the code runs in the parent of the node with the shader)
extends Node2D
func _process(delta):
if Input.is_action_just_pressed("ui_accept"):
var tween = create_tween()
tween.tween_property($Icon, "material:shader_parameter/progress",1,0.5).set_trans(Tween.TRANS_QUAD)
tween.connect('finished', reset)
func reset():
$Icon.material.set_shader_parameter('progress',0)
After the animation is done I want to image to disappear and be ready to reappear when a button is pressed again. For that purpose I added the reset function that gets triggered when the tween is done.
That last part is the problem: When I run the shader via the tween for the first time it works just fine but after that it doesn't work anymore even though the value of progress was reset to 0. Am I missing something? I don't really get why it doesn't work anymore.