what is this "get_isActiveAndEnabled can only be called from the main thread....." Please help??
why unity shows this message? get_isActiveAndEnabled can only be called from the main thread.Constructors and field initializers will be executed from the loading thread when loading a scene.Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function. UnityEngine.UI.Text:set_text(String)loader:DownloadFileCompleted(Object, AsyncCompletedEventArgs) (at Assets/loader.cs:29)System.Net.WebClient:m__E(Object)
Please help?
using UnityEngine; using System; using UnityEngine.UI; using System.Net;
public class loader : MonoBehaviour { public Text mesaj; public string filename,filename2;
public void dosyaoku()
{
WebClient client = new WebClient();
client.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(DownloadFileCompleted);
filename2 = Application.dataPath + "/" + "FiyatListesi.csv";
client.DownloadFileAsync(new Uri("https://docs.google.com/spreadsheets/d/mysheetid/export?format=csv&id="mysheetid&gid=gidnumber"), filename2);
}
void DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
{
if (e.Error == null)
{
AllDone();
}
else
{
mesaj.text = e.Error.Message;
}
}
private void AllDone()
{
mesaj.text = "file downloaded";
}
}
Your answer
Follow this Question
Related Questions
(android build) Unable to initialize unity engine 2 Answers
Animator not initialized "cautions" 0 Answers
Hello, I have problem with building a project on Android with Vuforia 0 Answers
Unity package manage error 0 Answers
InvalidCastException: Cannot cast from source type to destination type 0 Answers