Get the existing atlas names and their unique ids by checking the names of the files already in the save directory. Using the found unique ids, create a unique name for the newly generated atlas.
This fixes #52 and similar errors that occur when trying to atlas materials that start with "materialatlas" but are either missing a second underscore, have extra underscores or have a "unique_id" which isn't numeric, by replacing the code in question.
This also fixes a very small chance of generated atlases overwriting existing atlas image files in the save directory, since the randomly chosen unique_id could end up being the same as an already existing file in the save directory.
Formatting the unique_id to always display at least 5 digits is probably a bit excessive, but I did it to match the previous unique ids that would always be 5 digits. If you want, reduce it by changing the 5 in {0:05d} to a smaller number.
With this change, the ids are no longer random and instead start from 1 and increment until a unique id is found. I couldn't see a reason that they needed to remain random.
unique_id
could end up being the same as an already existing file in the save directory.Formatting the
unique_id
to always display at least 5 digits is probably a bit excessive, but I did it to match the previous unique ids that would always be 5 digits. If you want, reduce it by changing the 5 in{0:05d}
to a smaller number. With this change, the ids are no longer random and instead start from 1 and increment until a unique id is found. I couldn't see a reason that they needed to remain random.