Example #1
0
    public void DownloadAndSave(string key)
    {
        System.Array values = System.Enum.GetValues(typeof(DocsNumber));

        foreach (DocsNumber val in values)
        {
            int id = (int)val;

            if (id == (int)DocsNumber.Max)
            {
                PlayerPrefs.SetInt("DocsDown", 1);
                IsEndDocsDown = true;
                return;
            }

            string url = string.Format(GoogleSheetBaseUrl, key, id);
            WWW    www = new WWW(url);
            while (www.isDone == false)
            {
                ;
            }

            string name = "";
#if UNITY_EDITOR
            name = string.Format("Resources/config/{0}.txt", id);
#else
            name = id.ToString();
#endif

            string path = GameDefine.pathForDocumentsFile(name);

            Debug.Log("Docs path URL => " + path);

#if UNITY_EDITOR
            //CLog.Log(string.Format("###################### DownloadAndSave / id = {0} / www.text = {1}", id, www.text));
#endif

            string str = www.text;

            str = Utils.parseJson(str.Split(new char[] { '\n', '\r' }, System.StringSplitOptions.RemoveEmptyEntries));

            File.WriteAllText(path, str);

            DestroyImmediate(this);
        }

        IsEndDocsDown = true;
    }