I want to create a list of the contents of a folder placed inside “StreamingAssets/Resources” and load each file (they’re all image files) into a texture Dictionary using “Resources.Load()”. The plan is to load the contents of a different folder every time the player changes the preferred language.
It works great both in the Editor and if I build a Windows version (haven’t tried iPhone yet as I don’t have a Mac, but I guess it should work). The problem is I’m not sure how to deal with the WWW class in the Android build (and Android is supposed to be the main release platform). I tried to follow some of the solutions in similar questions, but didn’t seem to work for me…
Any ideas, please???
//Loads all the localised images of the active language
public void LoadLocalisedImages() {
string imagesDirectory = "";
if (Application.platform == RuntimePlatform.IPhonePlayer)
{
imagesDirectory = Application.dataPath + "/Raw/Resources/" + Localisation.languagePath + "Images/";
}
else if (Application.platform == RuntimePlatform.Android)
{
//???
}
else
{
imagesDirectory = Application.dataPath + "/StreamingAssets/Resources/" + Localisation.languagePath + "Images/";
}
DirectoryInfo dir = new DirectoryInfo(imagesDirectory);
FileInfo[] info = dir.GetFiles("*.*");
foreach (FileInfo fi in info)
{
string fileExtension = fi.Extension;
if (fileExtension != ".meta")
{
string imageName = Path.GetFileNameWithoutExtension(fi.Name);
localisedImages[imageName] = Resources.Load(Localisation.languagePath + "Images/" + imageName) as Texture2D;
}
}
}