Пример #1
0
    IEnumerator DownloadAudioClip(string file_name)
    {
        string url = "https://matthewriddett.com/static/mludlc/" + "sound/" + file_name + ".wav";

        using (UnityWebRequest www = UnityWebRequest.Get(url))
        {
            yield return(www.SendWebRequest());

            if (www.isNetworkError || www.isHttpError)
            {
                Debug.Log(www.error);
            }
            else
            {
                controller.SaveDLCAudioClip(www.downloadHandler.data, file_name);
                //string savePath = string.Format("{0}/{1}.wav", Application.persistentDataPath + "/WordAudio/", file_name);
                //System.IO.File.WriteAllBytes(savePath, www.downloadHandler.data);
                Debug.Log("Saving " + file_name + " audioclip.");
            }
        }

        doneWordDownloadStep = true;
    }