WWW无法在iOS [Unity]上下载文件

时间:2018-06-13 04:58:31

标签: ios xcode file unity3d download

我正在制作一个fortnite-guide应用程序,其中显示了战斗通行证任务&一些提示,一切都存储在json文件中,所以我基本上想下载那个子文件来加载数据...... 这是我的代码:

using UnityEngine;
using System.Collections;
using System.IO;
using System;
using System.Collections.Generic;

public class GetData : MonoBehaviour {

    public static GetData Instance = null;

    private List<Weeks> publicWeeks = new List<Weeks>();
    private bool dataLoaded = false;
    private string errorText;

    public string ErrorText {
        get { return errorText; }
    }

    public List<Weeks> PublicWeeks {
        get { return publicWeeks; }
    }

    public bool DataLoaded {
        get { return dataLoaded; }
    }

    void Awake() {
        if(Instance == null)
            Instance = this;
        else if(Instance != this)
            Destroy(gameObject);

        DontDestroyOnLoad(gameObject);
    }

    void Start () 
    {
        string url = "https://d7coins.com/fgdata.json";
           WWW www = new WWW(url);
           StartCoroutine(WaitForRequest(www));
   }

    string fixJson(string value) {
        value = "{\"Items\":" + value + "}";
        return value;
    }

  IEnumerator WaitForRequest(WWW www) {
      yield return www;

      // check for errors
      if (www.error == null)
      {
          string jsonString = fixJson(www.text);
          Weeks[] weeksArray = JsonHelper.FromJson<Weeks>(jsonString);

          for(int i = 0; i < weeksArray.Length; i++) {
              publicWeeks.Add(weeksArray[i]);
          }

          dataLoaded = true;
      } else {
          dataLoaded = false;
          errorText = ("WWW Error: "+ www.error);
      } 
  }

}

[Serializable]
    public class Weeks {
        public int week;
        public string quest;
        public string tips;
    }

当我在Unity中运行它时它工作正常,但是在iDevice上运行它因某些原因无法下载文件...

这是Xcode日志: https://pastebin.com/D8ei4MMi

任何帮助将不胜感激,并提前感谢:)

0 个答案:

没有答案