How can I trigger re-import assets?
This code would work fine if the exact same texture wasn’t loading all the time. Unless I open the editor window, it just won’t load properly, so I’m looking for either a fix for this or an alternative code that enables me to load the new texture
var texture = ResourceLoader.load(ruta) if ResourceLoader.exists(ruta) else default
sprite.texture = texture
the file was saved before by
func screenshot():
var captura = get_viewport().get_texture().get_image()
captura.save_png(“res://screenshot.png”)
I made sure that all routes and references are fine
var texture = ResourceLoader.load(ruta, “”, 2) if ResourceLoader.exists(ruta) else default
It didn’t work, I also tried with some type_hint such as Image or Texture but nothing worked, maybe it has something to do with ProjectSettings.editor/export/convert_text_resources_to_binary
I am going to check it
I finally solved it, but it works fine either using user:// or res:// (anyways I decided to use user://)
I just set at top of the code
var image = Image.load_from_file(“user://screenshot.png”)
then I swapped the code to:
var texture = ImageTexture.create_from_image(image) if image else default
background.texture = texture
I just copied it from the docs. Files can be stored in res and also saved, but I think that Image.load_from_file("user://screenshot.png")
is the line that fixed everything, thank you so much for all the help