This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

I'm trying to add files to a tree inside my editor plugin. So far, it's working well. I can retrieve a list of all files in the res:// folder, and add them to the tree, just like the native FileSystem does.

I'd like to filter out my tree, so that it only adds my custom AudioEvent resource. I have access to the full path of all my files, but I don't know how to convert those into something where I can find out what type of resource each file is, since they all have the .tres extension.

Does anyone know how I can achieve this?

Godot version 3.5
in Engine by (21 points)

1 Answer

0 votes

Huh, just after asking, I figured out an answer.

var res = load(filepath) as AudioEvent
if res != null:
    print("This is a custom AudioEvent resource")

load() is pretty taxing, so I make sure to do some additional checks before this to make sure I'm not loading all files of the entire project. I check that this is a resource file first, for example. This can be done by checking that the extension is .tres.

by (21 points)
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.