- Home /
Question by
payalzariya07 · Nov 29, 2018 at 01:29 PM ·
c#unity 5unityeditor
unity showing download file delay
WebClient client;
public void DownloadFile() { client = new WebClient();
client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
client.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler( DownloadFileCompleted );
client.DownloadFileAsync (new Uri(url), getPath() + "DEMO.xml");
}
void DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
{
if (e.Error == null)
{
Debug.Log ("Completed");
} else
Debug.Log (e.Error.ToString ());
}
void client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
}
private string getPath(){
#if UNITY_EDITOR
return Application.dataPath + "/Resources/";
#elif UNITY_ANDROID
return Application.persistentDataPath + "/Resources/";
#elif UNITY_IPHONE
return GetiPhoneDocumentsPath()+"/";
#else
return Application.dataPath +"/";
#endif
}
Comment