質問編集履歴
1
ソースコードの修正
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -6,21 +6,28 @@
|
|
|
6
6
|
```c#
|
|
7
7
|
using UnityEngine.Networking;
|
|
8
8
|
|
|
9
|
+
void Start () {
|
|
10
|
+
ReadData();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public string textdata = "";
|
|
14
|
+
|
|
9
15
|
public void ReadData(){
|
|
10
|
-
|
|
16
|
+
StartCoroutine (GetProblem ());
|
|
11
|
-
|
|
17
|
+
// ↓このdebug.logでtextdataが空になってしまう
|
|
18
|
+
Debug.Log ("finished: " + textdata);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public IEnumerator GetProblem(){
|
|
12
22
|
UnityWebRequest www = UnityWebRequest.Get ("http://xxx.xxx.xxx.xxx/xxx.txt");
|
|
13
|
-
|
|
23
|
+
yield return www.Send ();
|
|
14
24
|
|
|
15
25
|
if (www.isError) {
|
|
16
26
|
Debug.Log (www.error);
|
|
17
27
|
} else {
|
|
18
28
|
textdata = www.downloadHandler.text;
|
|
29
|
+
// ここでは表示される Debug.Log (textdata);
|
|
19
30
|
}
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
Debug.Log(textdata);
|
|
24
31
|
}
|
|
25
32
|
|
|
26
33
|
```
|