#Is there a way to get the sub-directories from a directory?

2 messages · Page 1 of 1 (latest)

fresh peak
#

So I'm using the following code to get all the resources in this folder:

    _objects.clear()
    var path = "res://Assets/Resources/ObjectResource/"
    var dir = DirAccess.open(path)
    print("Directory Files: " + str(dir.get_files()))
    for file in dir.get_files():
        var file_path = str(path) + str(file)
        print("Files Path: " + file_path)
        var object = load(file_path)
        _objects.append(object)```

The `_objects` array is just an array of resources.

But the "/ObjectResource/" folder has folders inside it that I would like to search for resources as well.

I could make more paths and do it that way but is there any way to search a Directory for subfolders without specifying those paths?
feral warren
#

Just like there is the get_files() function there is also a get_directories() function