Copy PNG file using dir.copy() to res:// folder and using it as texture.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By MathieuJazz

Hey folks, I’m having a particular issue… I searched a lot on the internet and what I’m trying to do is quite simple actually, but I can’t find anything to make it work!

So, I want the user to be able to pick a PNG file from a FileDialog window (using file system) and then, my code would copy it in the resource folder (with dir.copy(source, dest)). Everything work fine for this part, but I can’t manage to use this very PNG file freshly imported.

BTW, I noticed that no .import file gets generated while copying the file in the resource folder from code (which really seems to be the problem). If I come back to the editor, the .import file is automatically generated and now, it works.

Is there a way to force a “scan” in the res folder while running? Or force generate a .import file?

Anyway… Any twist or turn around? I’m surely doing it the wrong way… Any advice is welcome! :slight_smile:

Here’s a piece of code :

var dir = Directory.new()
dir.copy(source, dest)
#This works!
get_node(txtr_image).texture = load(previs_image)
#This doesn't! No loader found error...

Thank you for your time!
Math

No one can help me? :frowning:

MathieuJazz | 2022-09-21 14:34

Here’s a related discussion that may be helpful…

Loading a external image if it exists as Sprite2D texture on program start - Archive - Godot Forum

jgodfrey | 2022-09-21 16:48