質問編集履歴

1

ソースコードの修正

2017/08/07 02:11

投稿

kz23szk
kz23szk

スコア85

test CHANGED
File without changes
test CHANGED
@@ -14,15 +14,35 @@
14
14
 
15
15
 
16
16
 
17
+ void Start () {
18
+
19
+ ReadData();
20
+
21
+ }
22
+
23
+
24
+
25
+ public string textdata = "";
26
+
27
+
28
+
17
29
  public void ReadData(){
18
30
 
19
- string textdata = "";
31
+ StartCoroutine (GetProblem ());
20
32
 
21
-
33
+ // ↓このdebug.logでtextdataが空になってしまう
34
+
35
+ Debug.Log ("finished: " + textdata);
36
+
37
+ }
38
+
39
+
40
+
41
+ public IEnumerator GetProblem(){
22
42
 
23
43
  UnityWebRequest www = UnityWebRequest.Get ("http://xxx.xxx.xxx.xxx/xxx.txt");
24
44
 
25
- yield return www.Send ();
45
+ yield return www.Send ();
26
46
 
27
47
 
28
48
 
@@ -34,15 +54,9 @@
34
54
 
35
55
  textdata = www.downloadHandler.text;
36
56
 
57
+ // ここでは表示される Debug.Log (textdata);
58
+
37
59
  }
38
-
39
-
40
-
41
- }
42
-
43
-
44
-
45
- Debug.Log(textdata);
46
60
 
47
61
  }
48
62