I can load a textures with:
Texture2D texture = ContentManager.Load<Texture2D>(assetName);
But this throws an exception if the file doesn't exist. Is there a way to determine if a requested asset of a given name actually exists first?
I'm storing a series of assets using suffixed number counters (art001.png, art002.png, ...) and would like to have a simple call preload the textures by just counting through them.
It is not possible to iterate through the contents of your XAP file. You'll just have to maintain a list of the assets you wish to load.
I had a similar problem with my app, I ended up writing a simple script that looked in a particular folder for a matching filename pattern and updating a text file. So, I'd run the script before building the app, the text file gets packaged and read in the app to determine what files could be loaded. Or you can skip the trouble and maintain a list in code by hand.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With