{"id":811,"date":"2016-02-24T17:18:47","date_gmt":"2016-02-24T08:18:47","guid":{"rendered":"http:\/\/nantoka.filmm.info\/blog\/?p=811"},"modified":"2016-02-24T17:18:47","modified_gmt":"2016-02-24T08:18:47","slug":"%e6%94%b9%e8%a8%82%e7%89%88%ef%bc%9acsv%e8%aa%ad%e3%81%bf%e8%be%bc%e3%81%bf","status":"publish","type":"post","link":"https:\/\/nantoka.filmm.info\/blog\/?p=811","title":{"rendered":"\u6539\u8a02\u7248\uff1aCSV\u8aad\u307f\u8fbc\u307f"},"content":{"rendered":"<p>CSV\u306e\u30c6\u30ad\u30b9\u30c8\u306f\u30c6\u30ad\u30b9\u30c8\u5185\u306b\\n\u3068\u304b\u3044\u3066\u3066\u3082\uff0c\u6539\u884c\u3068\u8a8d\u8b58\u3055\u308c\u306a\u3044\uff0e\u305d\u3053\u3067\uff0c\u5f37\u5236\u7684\u306b@\u3092\u6539\u884c\u30b3\u30fc\u30c9\u306b\u8aad\u307f\u66ff\u3048\u308b\u65b9\u6cd5\u3067\u56de\u907f\u3059\u308b<\/p>\n<p>\u30c6\u30ad\u30b9\u30c8\u306e\u6539\u884c\u30ab\u6240\u306b\u534a\u89d2\u306e@\u3092\u5165\u308c\u308b\uff0e\u305d\u3053\u304c\u6539\u884c\u3055\u308c\u308b\uff0e<\/p>\n<pre class=\"lang:default decode:true \">using UnityEngine;\r\nusing System;\r\nusing System.Collections;\r\nusing System.Collections.Generic;\r\nusing System.IO;\/\/use for file read\r\nusing UnityEngine.UI;\/\/use unity gui\r\n\r\npublic class quiz : MonoBehaviour {\r\n\t\/\/public string[] qq;\r\n\t\/\/ Use this for initialization\r\n\r\n\r\n\tpublic ArrayList qq =new ArrayList();\/\/question store to this array\r\n\tprivate int no;\/\/this means number\r\n\tpublic int maxQ = 3;\/\/count of quiz\r\n\tpublic Text quizText, kaisetsu; \/\/Text\u7528\u5909\u6570\r\n\tpublic Text bt1,bt2,bt3,bt4;\/\/for assign btn tex\r\n\tpublic int answer;\/\/answer number\r\n\tpublic int selected;\/\/selected btn\r\n\t\/\/public Toggle tog1, tog2, tog3, tog4;\r\n\tpublic ToggleGroup tgg1;\/\/select btn group\r\n\r\n\tpublic GameObject kaisetsuPanelAlert;\r\n\tpublic GameObject seikaiPanelAlert;\r\n\tpublic GameObject ngPanelAlert;\r\n\tpublic GameObject selectAlert;\r\n\r\n\tvoid Start () {\r\n\r\n\t\t\/\/Android is load from streming Assets floder\r\n\t \/\/\r\n\t\t\/\/jar:file:\/\/\" + Application.dataPath + \"!\/assets\" + \"\/\";  \/\/example\r\n\t\t\/\/\r\n\/\/\t\tTextAsset csv = Resources.Load(\"question\") as TextAsset;\r\n\/\/\t\tStringReader reader = new StringReader(csv.text);\r\n\/\/\t\twhile (reader.Peek () &gt; -1) {\r\n\/\/\t\t\tstring line = reader.ReadLine ();\r\n\/\/\t\t\tstring[] values = line.Split (',');\r\n\/\/\t\t\tDebug.Log (values[0]);\r\n\/\/\t\t}\r\n\t\tkaisetsuPanelAlert.SetActive (false);\r\n\t\tseikaiPanelAlert.SetActive (false);\r\n\t\tngPanelAlert.SetActive (false);\r\n\t\tselectAlert.SetActive (false);\r\n\t\t\/\/\r\n\t\tno = 0;\/\/initialize of quiz count\r\n\r\n\t\t\/\/ArrayList qq =new ArrayList();\r\n\t\tTextAsset csv = Resources.Load(\"question\") as TextAsset;\r\n\t\tStringReader reader = new StringReader(csv.text);\r\n\t\twhile (reader.Peek () &gt; -1) {\r\n\t\t\tqq.Add (reader.ReadLine ());\r\n\t\t}\r\n\r\n\t\t\/\/Debug.Log ((string)qq[1]);\r\n\t\tqread ();\/\/show first question\r\n\t}\r\n\t\r\n\t\/\/ Update is called once per frame\r\n\tvoid Update () {\r\n\t\r\n\t}\r\n\r\n\r\n\r\n\tpublic void tog1press(){\r\n\t\tanswer = 1;\r\n\t}\r\n\r\n\tpublic void tog2press(){\r\n\t\tanswer = 2;\r\n\t}\r\n\r\n\tpublic void tog3press(){\r\n\t\tanswer = 3;\r\n\t}\r\n\r\n\tpublic void tog4press(){\r\n\t\tanswer = 4;\r\n\t}\r\n\r\n\tpublic void qread(){\/\/next mondai\r\n\r\n\t\/\/\tfor(no  = 0; no &lt; maxQ; no++){\r\n\t\t\t\r\n\t\ttgg1.SetAllTogglesOff();\r\n\t\tstring qqq=(string)qq[no];\r\n\t\tstring[] values = qqq.Split(',');\/\/values is string array\r\n\r\n\r\n\t\t\/\/GameObject.Find (\"SectionText\").GetComponent&lt;Text&gt;().text=Section[ int.Parse(values[0]) ];\r\n\t\/\/\tstring atxt = \"\";\r\n\t\/\/\tstring atxt1 = \"\";\r\n\t\/\/\tstring atxt2 = \"\";\r\n\t\/\/\tstring atxt3 = \"\";\r\n\/\/\t\tint mode = Random.Range (0, 10);\r\n\/\/\t\tif (mode == 0)\r\n\/\/\t\t{\r\n\/\/\t\t\tatxt=values[2];GoodNo=1;\r\n\/\/\t\tatxt1=values[1];\r\n\/\/\t\t\tatxt2=values[4];\r\n\/\/\t\t\tatxt3=values[5];\r\n\/\/\t\t}\r\n\r\n\t\tstring test1 = (string)values[0];\r\n\t\/\/\tquizText.text = (string)values[0];\r\n\t\tquizText.text = test1.Replace(\"@\", \"\\n\");\r\n\r\n\t\tselected = int.Parse((string)values [1]);\/\/csv is text, so, covert to string\r\n\t\tbt1.text = (string)values[2];\r\n\t\tbt2.text = (string)values[3];\r\n\t\tbt3.text = (string)values[4];\r\n\t\tbt4.text = (string)values[5];\r\n\r\n\t\tstring kaisetsuKaigyou = (string)values[6];\r\n\t\tkaisetsu.text = kaisetsuKaigyou.Replace(\"@\", \"\\n\");\r\n\t\t\/\/kaisetsu.text = (string)values[6];\r\n\r\n\t\tif (no &lt; maxQ) { \/\/quiz count limit\r\n\t\t\tno++;\r\n\t\t}else{\r\n\t\t\tno = maxQ; \/\/kokode resulthe,,\r\n\t\t}\r\n\r\n\/\/\t\tDebug.Log(tgl);\r\n\t\t\/\/}\r\n\t}\r\n\r\n\r\n\tpublic void answerCheck(){\r\n\t\t\/\/Boolean selectCheck = tgg1.AnyTogglesOn;\r\n\t\tif (!tgg1.AnyTogglesOn()) {\r\n\t\t\tselectAlert.SetActive (true);\r\n\t\t\treturn;\r\n\t\t}\r\n\t\t\tif (selected == answer) {\r\n\t\t\tseikaiPanelAlert.SetActive (true);\r\n\t\/\/\t\tDebug.Log (\"seikai\");\r\n\t\t} else {\r\n\t\t\tngPanelAlert.SetActive (true);\r\n\t\t\/\/\tDebug.Log (\"No!\");\r\n\t\t}\r\n\t}\r\n\r\n\tpublic void hideKaisetsuPanel(){\r\n\t\tkaisetsuPanelAlert.SetActive (false);\r\n\t\tqread ();\r\n\t}\r\n\r\n\tpublic void showKaisetsunOK(){\r\n\t\tseikaiPanelAlert.SetActive (false);\r\n\t\tkaisetsuPanelAlert.SetActive (true);\r\n\t}\r\n\tpublic void showKaisetsuNG(){\r\n\t\tngPanelAlert.SetActive (false);\r\n\t\tkaisetsuPanelAlert.SetActive (true);\r\n\t}\r\n\r\n\tpublic void hideSelecyAlert(){\r\n\t\tselectAlert.SetActive (false);\r\n\t}\r\n\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>CSV\u306e\u30c6\u30ad\u30b9\u30c8\u306f\u30c6\u30ad\u30b9\u30c8\u5185\u306b\\n\u3068\u304b\u3044\u3066\u3066\u3082\uff0c\u6539\u884c\u3068\u8a8d\u8b58\u3055\u308c\u306a\u3044\uff0e\u305d\u3053\u3067\uff0c\u5f37\u5236\u7684\u306b@\u3092\u6539\u884c\u30b3\u30fc\u30c9\u306b\u8aad\u307f\u66ff\u3048\u308b\u65b9\u6cd5\u3067\u56de\u907f\u3059\u308b \u30c6\u30ad\u30b9\u30c8\u306e\u6539\u884c\u30ab\u6240\u306b\u534a\u89d2\u306e@\u3092\u5165\u308c\u308b\uff0e\u305d\u3053\u304c\u6539\u884c\u3055\u308c\u308b\uff0e using UnityEngine; &hellip; <a href=\"https:\/\/nantoka.filmm.info\/blog\/?p=811\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">\u6539\u8a02\u7248\uff1aCSV\u8aad\u307f\u8fbc\u307f<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-811","post","type-post","status-publish","format-standard","hentry","category-1"],"_links":{"self":[{"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=\/wp\/v2\/posts\/811","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=811"}],"version-history":[{"count":1,"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=\/wp\/v2\/posts\/811\/revisions"}],"predecessor-version":[{"id":812,"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=\/wp\/v2\/posts\/811\/revisions\/812"}],"wp:attachment":[{"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=811"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=811"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=811"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}