Этот код прекрасно работает для Android, он правильно загружает требуемое изображение, но в iOS он показывает знак вопроса, где изображение должно присутствовать.
Я что-то здесь упускаю? Как я могу изменить этот код, чтобы он был совместим с Ios тоже. Что нужно сделать по-другому, чтобы IOS работал?
Также я должен отметить, что я загружаю изображение из Amazon Web Service
public class ItemImage : MonoBehaviour {
public static ItemImage instance = null;
//public UnityEngine.UI.Dropdown ddlCountries;
public string getImagesUrl = "This is left blank intentionally";
// Use this for initialization
public int nrDays = 2;
public string [] extTypes = {"*.jpg", "*.png"};
bool hasConnection = false;
int dataUpdated = 0;
List<string> ListItemImages;
List<string> ListItemDates;
List<string> imgList;
ItemImageObject[] Entities;
AccessAwss3Code awss3;
void Start () {
imgList = new List<string>();
StartCoroutine(StartGetData());
}
void Awake()
{
if (instance == null)
instance = this;
//If instance already exists and it's not this:
else if (instance != this)
Destroy(gameObject);
DontDestroyOnLoad(gameObject);
}
public IEnumerator StartGetData() {
Debug.Log("in StartPage()");
yield return StartCoroutine(GetWebServiceData());
awss3 = this.gameObject.GetComponent<AccessAwss3Code>();
if (hasConnection)
GetNewImages();
else{
loadimgList();
}
}
IEnumerator GetWebServiceData()
{
dataUpdated = 0;
using (UnityWebRequest www = UnityWebRequest.Get(getImagesUrl))
{
yield return www.Send();
if (www.isNetworkError || www.isHttpError)
{
hasConnection = false;
Debug.Log(www.error);
}
else
{
if (www.isDone)
{
hasConnection = true;
string jsonResult =
System.Text.Encoding.UTF8.GetString(www.downloadHandler.data);
Entities=JsonHelper.getJsonArray<ItemImageObject(jsonResult);
ListItemImages = Entities.Select(p=>p.image).ToList();
ListItemDates =
Entities.Select(p=>p.msgdate).ToList();
}
}
}
}
void GetNewImages()
{
string rootSavePath =
Path.Combine(Application.persistentDataPath, "data");
rootSavePath = Path.Combine(rootSavePath, "images");
Debug.Log(rootSavePath);
int state = 0;
for(int i=0; i < ListItemImages.Count; i++)
{
string DirInPath = null;
string fileNameIn = null;
string FileNamePathIn = GetFileName(ListItemImages[i], ref
fileNameIn, ref DirInPath);
string directory = Path.Combine(rootSavePath,DirInPath);
Debug.Log(directory);
if (!Directory.Exists(directory))
Directory.CreateDirectory(directory);
fileNameIn = ListItemDates[i] + "_" + fileNameIn;
string OutFileName = Path.Combine(directory,fileNameIn);
Debug.Log(OutFileName);
imgList.Add(OutFileName);
if(!File.Exists(OutFileName))
state = awss3.GetObject(FileNamePathIn, OutFileName);
}
if (state == 0)
dataUpdated = 1;
saveimgList();
DeleteOldImage(rootSavePath);
}