Is there a way to reload an image while running?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Zeero
:warning: Old Version Published before Godot 3 was released.

I’m checking if a .png file was updated on the server and overwritting it if it’s different from the server image, but it only updates if I close the game and start it again, even reloading scene don’t work, am I misunderstanding something? Is it even possible?

:bust_in_silhouette: Reply From: volzhs
func _ready():
	get_node("Sprite").set_texture(ResourceLoader.load("res://icon.png", "", true))
	get_node("Button").connect("pressed",get_tree(),"reload_current_scene")

It still don’t work. I edit the file locally, it correctly checks that the local file is different from the server one and download it, but ingame it still is the old image (even being updated at file manager)

Zeero | 2017-11-27 21:17

did you reload current scene?
or did you reload texture and assign it again?
it’s not updated magically when png is changed.

volzhs | 2017-11-27 21:22

That’s exactly what I want, When I run the game, I want it to check if a texture was changed on the server, if it is, I overwrite the local texture succesfully, I do reload the scene, but I can’t manage to “reload and assign it again” while running, it saves the new texture on the file system but ingame it still uses the old texture.

Zeero | 2017-11-27 21:29

I can’t figure out what was wrong then.
I tested this code locally.
run game > change icon.png manually > click button to reload > I got new texture(icon.png)
there was no problem.

did you test with exported game?

volzhs | 2017-11-27 21:34

Actually it worked with exported game, but with the editor it don’t work until I click back on the editor and it updates that the file changed, when I go back and click the button to reload scene it works.

Zeero | 2017-11-27 22:03