How do you detect new resources in res:// ?

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

I have an EditorPlugin that I am writing, and I’m trying to figure out how to get a signal running whenever a new file is added to the res:// directory. I can’t seem to find which class in the API would enable me to respond to newly added files.

:bust_in_silhouette: Reply From: Matt_UV

I think you can get the file and directory list of the res:// directory.
Save it into a list or a file if you want to keep it.
Then in the process function, keep checking the file list and compare it to what you already have.
You can even iterate through sub folders if you want.
Check this page of the doc: http://godotengine.org/en/stable/classes/class_directory.html

Yes, but that would be exceedingly inefficient. I was hoping for some sort of signal-oriented approach. Thankfully, it seems that 3.0 added a class to assist with this. This would be the approach necessary for a 2.1 project however.

Will Nations | 2017-10-27 12:32

Thank you for helping eveybody by answering your own question with a more efficient way!

Matt_UV | 2017-10-27 17:43

:bust_in_silhouette: Reply From: Will Nations

Godot 3.0 adds the new class EditorFileSystem which emits a signal when the filesystem is changed. You can then run a recursive traversal of the resource directories (using EditorFileSystemDirectory or just Directory) to update your GUI ONLY when you know its possible for updates to be needed. That way you aren’t just constantly scanning and re-scanning the resource directory.