The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

+1 vote

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.

in Engine by (186 points)

2 Answers

+1 vote
Best answer

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.

by (186 points)
0 votes

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:

by (255 points)

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.

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.