I am trying to read a text file which is placed on Server. Its a text file. I am able to read it but the problem is if Internet is slow it stuck the game for a while. May be I need to run this task as Asynchronous but I am not able to do this. I cant find any reasonable help online.
Please let me know how can I run a task in background or Asynchronously in Unity. Here is the function which I want to be executed in background.
private void readFile()
{
Debug.Log("Trying to Read");
WebClient client = new WebClient();
Stream stream = client.OpenRead("my text file url.txt");
reader = new StreamReader(stream);
result = reader.ReadToEnd();
Debug.Log(result);
}
Looking forward for quick help. Thanks