【发布时间】:2014-12-22 16:52:19
【问题描述】:
我正在尝试读取放置在服务器上的文本文件。它是一个文本文件。我能够阅读它,但问题是如果互联网速度很慢,它会卡住游戏一段时间。 可能我需要以异步方式运行此任务,但我无法做到这一点。我在网上找不到任何合理的帮助。
请告诉我如何在后台运行任务或在 Unity 中异步运行。 这是我想在后台执行的功能。
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);
}
期待快速帮助。 谢谢
【问题讨论】:
标签: c# asynchronous unity3d