前提・実現したいこと
CSVファイルのデータ(1961~2017年、1961~2017年の日本の人口、1961~2017年の日本の人口増加率)を
Application.logMessageReceived()を使わずにゲーム実行中に全てのデータをPanel上のテキストに表示させたいです
発生している問題・エラーメッセージ
全てのデータをPanel上のテキストに表示させたいのですが、
一行ずつ上書きされてしまうため結局最後の1行のデータしか表示されません
該当のソースコード
C#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4 5using UnityEngine.UI; 6public class TextManager : MonoBehaviour { 7 8 public GameObject JPNPop_obj = null; 9 public List<Quest> quests = new List<Quest>(); 10 11 12 // Use this for initialization 13 void Start () { 14 TextAsset questdata = Resources.Load<TextAsset>("JapanesePop1"); 15 16 Text JPNPop = JPNPop_obj.GetComponent<Text>(); 17 18 string[] data = questdata.text.Split(new char[] { '\n' });//'\n'(改行)ごとにdataに入れる 19 20 for (int i = 1; i < data.Length - 1; i++)// i=0に入いるのはデータの名前なのでデータ自体はi=1から 21 { 22 string[] row = data[i].Split(new char[] { ',' });//,ごとにrowに入れる 23 24 if (row[1] != "") 25 { 26 Quest q = new Quest(); 27 28 int.TryParse(row[0], out q.Jahr); 29 float.TryParse(row[1], out q.PopulationJapan); 30 float.TryParse(row[2], out q.JapanChange); 31 JPNPop.text = q.Jahr + "," + q.JapanChange + "," + q.Birthrate; 32 Debug.Log(q.Jahr + "," + q.JapanChange + "," + q.Birthrate); 33 quests.Add(q); 34 } 35 }
C#
1public class Quest { 2 3 public int Jahr; 4 public float PopulationJapan; 5 public float JapanChange; 6}
補足情報
Debug.LogでConsoleには57個無事表示されました。
Unity2017.3.1f
Windows10
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/04/12 22:29
2019/04/12 22:36
2019/04/13 00:59 編集
2019/04/13 01:02 編集
2019/04/13 01:15
2019/04/13 01:17