0 votes

I am trying to load all of the textures from a directory into an array for easy access later using the instructions here


But when I see the order they are being put into the array, it doesn't make much sense, it looks kind of random. Is there any way to sort the directory alphabetically when it has been opened, so that get_next() iterates through the directory alphabetically, for example?

in Engine by (258 points)

1 Answer

0 votes
Best answer

You could certainly do it in a few, discrete steps. Something like:

  • Load an array with all of the file names
  • Sort the array (via Array.sort())
  • Iterate through the sorted array and load the textures
by (13,806 points)
selected by

This is actually exactly what I ended up doing. I do think it's a bit odd that there's no way to sort directories, though.

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.