{"id":2571,"date":"2017-10-24T20:18:19","date_gmt":"2017-10-24T11:18:19","guid":{"rendered":"http:\/\/nantoka.filmm.info\/blog\/?p=2571"},"modified":"2017-10-25T11:28:29","modified_gmt":"2017-10-25T02:28:29","slug":"%e9%85%8d%e7%bd%ae%e7%a2%ba%e8%aa%8d","status":"publish","type":"post","link":"https:\/\/nantoka.filmm.info\/blog\/?p=2571","title":{"rendered":"\u914d\u7f6e\u78ba\u8a8d"},"content":{"rendered":"<p>\u914d\u7f6e\u78ba\u8a8d\uff08\u672a\u5b8c\u6210\uff092017\/10\/25\u3000AM11\u6642\u5909\u66f4<\/p>\n<pre class=\"lang:default decode:true\" title=\"dicPractice.cs\">using System.Collections;\r\nusing System.Collections.Generic;\r\nusing UnityEngine;\r\nusing UnityEngine.UI;\r\n\r\nusing System.Collections.Generic;\/\/\u5fc5\u305a\u5fc5\u8981\r\n\r\npublic class dicPractice : MonoBehaviour {\r\n\r\n\tpublic GameObject ballPre;\/\/\u30dc\u30fc\u30eb\u30d7\u30ec\u30d5\u30a1\u30d6\u7528\r\n\tpublic InputField numInput;\/\/\u30a4\u30f3\u30d7\u30c3\u30c8\u30d5\u30a3\u30fc\u30eb\u30c9\u7528\r\n\tpublic InputField scnNumInput;\/\/\u30a4\u30f3\u30d7\u30c3\u30c8\u30d5\u30a3\u30fc\u30eb\u30c9\u7528\r\n\r\n\tpublic Button subBtn;\/\/\u30b7\u30fc\u30f3\u623b\u308b\u30dc\u30bf\u30f3\r\n\tpublic Button addBtn;\/\/\u30b7\u30fc\u30f3\u6b21\u30dc\u30bf\u30f3\r\n\r\n\r\n\tDictionary&lt;int, List&lt;string&gt;&gt; timeList1;\/\/\u591a\u91cd\u5316Dictionary\r\n\tList&lt;string&gt; tempList ;\/\/\u30c6\u30f3\u30dd\u30e9\u30ea\u7528\u306eList\r\n\r\n\tList&lt;GameObject&gt; goList;\/\/\u751f\u6210\u3057\u305f\u30b2\u30fc\u30e0\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u5168\u30ea\u30b9\u30c8\r\n\tint scenceNum;\/\/\u73fe\u5728\u306e\u30b7\u30fc\u30f3\u756a\u53f7\u7528\u5909\u6570\r\n\r\n\tvoid Start () {\r\n\t\t\/\/Dictionary,List\u306e\u8ffd\u52a0\r\n\t\ttimeList1 = new Dictionary&lt;int, List&lt;string&gt;&gt; ();\r\n\t\ttempList = new List&lt;string&gt;();\r\n\r\n\t\tgoList = new List&lt;GameObject&gt; ();\r\n\r\n\t\t\/\/\u203b\u203b\u30b7\u30fc\u30f3\u756a\u53f7\u30bc\u30ed\u306f\u30b7\u30fc\u30f3\u304c\u7a7a\u306e\u610f\u5473\u306b\u5909\u66f4\r\n\t\tscenceNum = 0;\/\/\u73fe\u5728\u306e\u30b7\u30fc\u30f3\u756a\u53f7\u521d\u671f\u5316\/\/\u4fdd\u5b58\u30c7\u30fc\u30bf\u8aad\u307f\u8fbc\u307f\u6642\u306b\u306f\u30b7\u30fc\u30f3\u756a\u53f7\u3092\uff11\u4ee5\u4e0a\u306b\u3059\u308b\r\n\t\r\n\t\t\/\/\u30b7\u30fc\u30f3\u6570\u304c\u3044\u304f\u3064\u304b\u3042\u308b\u304b\u30c1\u30a7\u30c3\u30af\u3059\u308b\u7a7a\u306a\u30890\u3092\uff0c\r\n\t\tint scnDicCount = timeList1.Count;\r\n\t\tif(scnDicCount &lt; 1){\r\n\t\tscnNumInput.text = scnDicCount .ToString ();\/\/\u30b7\u30fc\u30f3\u756a\u53f7\u306e\u6570\u5b57\u3092\u6587\u5b57\u306b\u5909\u63db\r\n\t\t}else{\r\n\t\t\tscnNumInput.text = scenceNum.ToString ();\/\/Dictionary\u304c\u7a7a\u3067\u306a\u304b\u3063\u305f\u3089\u30b7\u30fc\u30f3\u756a\u53f7\u3092\u8868\u793a\u3055\u305b\u308b\uff08\u4fdd\u5b58\u6a5f\u80fd\u8ffd\u52a0\u5f8c\u306b\u6a5f\u80fd\u3059\u308b\uff09\r\n\t\t}\r\n\r\n\t\t\/\/\u30b7\u30fc\u30f3\u756a\u53f70\u4ee5\u4e0b\u306a\u3089\u6b21\u30b7\u30fc\u30f3\u30dc\u30bf\u30f3\u30aa\u30d5\u306b\r\n\t\tif (scenceNum &lt;= 1) {\r\n\t\t\tsubBtn.interactable = false;\r\n\t\t}\r\n\r\n\t\t\/\/\u30b7\u30fc\u30f3\u756a\u53f7\u304c\u30bc\u30ed\u3067\u623b\u308b\u30dc\u30bf\u30f3\u30aa\u30d5\u306b\r\n\t\t\taddBtn.interactable = false;\r\n\r\n\r\n\t\t\/\/json\u7528\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\r\n\t\tmyData jdata = new myData();\r\n\r\n\t\t\/\/\u30ad\u30e3\u30e910\u4f53\u4f5c\u6210\r\n\t\tfor (int i = 0; i &lt; 10; i++) {\r\n\t\t\tGameObject go = Instantiate (ballPre, new Vector3 (i * 2.0f, 0, 0), Quaternion.identity) as GameObject;\r\n\t\t\tstring myAIname =  \"AI\" + i.ToString ();\r\n\t\t\tgo.name = myAIname;\r\n\r\n\t\t\t\/\/goList\u306b \u751f\u6210\u3057\u305fgo\u3092goList\u306b\u8ffd\u52a0\r\n\t\t\tgoList.Add(go);\r\n\r\n\t\t}\r\n\r\n\t}\r\n\t\t\r\n\r\n\t\/\/\u756a\u53f7\u3067\u547c\u3073\u51fa\u3059\u7528\r\n\tpublic void numDel(){\r\n\t\tint objNum = int.Parse (numInput.text);\/\/\u30a4\u30f3\u30d7\u30c3\u30c8\u30d5\u30a3\u30fc\u30eb\u30c9\u3067\u53d7\u3051\u53d6\u3063\u305f\u756a\u53f7\u3092int\u306b\u5909\u63db\r\n\t\tint scnNum = int.Parse (scnNumInput.text);\/\/\u30a4\u30f3\u30d7\u30c3\u30c8\u30d5\u30a3\u30fc\u30eb\u30c9\u3067\u53d7\u3051\u53d6\u3063\u305f\u756a\u53f7\u3092int\u306b\u5909\u63db\r\n\t\tscnNum--;\/\/Dictionary\u306b\u306f0\u304b\u3089\u53ce\u7d0d\u3055\u308c\u3066\u3044\u308b\u306e\u3067\uff11\u5f15\u304f\r\n\t\tList&lt;string&gt; temp2List = new List&lt;string&gt; ();\/\/\u4e00\u6642\u7684\u306aList\u4f5c\u6210\r\n\r\n\t\tDebug.Log (\"\u547c\u3073\u51fa\u3057\u756a\u53f7_\" + objNum);\r\n\t\tDebug.Log (\"\u30b7\u30fc\u30f3\u756a\u53f7_\" + scnNum);\r\n\t\ttemp2List = timeList1 [scnNum];\/\/\u30b7\u30fc\u30f3\u756a\u53f7scnNum\u306eJSON\u3092LIST\u306b\u8aad\u307f\u8fbc\u3080\r\n\t\tvar myObject = JsonUtility.FromJson&lt;myData&gt;(temp2List [objNum]);\/\/\u30b7\u30fc\u30f3\u30bc\u30ed\u306eobjNum\u756a\u306eJSON\u306e\u307f\u3092\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u5909\u63db\r\n\t\tDebug.Log (\"X=\" + myObject.posx);\/\/\u30c7\u30d0\u30c3\u30b0\u7528\r\n\t\tDebug.Log (\"Z=\" + myObject.posz);\r\n\t\tDebug.Log (\"name=\" + myObject.name);\r\n\t\t\/\/Debug.Log (\"time=\" + myObject.time);\r\n\r\n\t}\r\n\r\n\r\n\t\/\/ \u30b7\u30fc\u30f3\u8ffd\u52a0\u7528\r\n\tpublic void dicAdd(){\r\n\r\n\t\/\/\tint dicCount = timeList1.Count;\/\/\u30b7\u30fc\u30f3\u756a\u53f7\u306e\u6700\u5927\u5024\u78ba\u8a8d\u7528\r\n\t\/\/\tscnNumInput.text = dicCount.ToString ();\/\/\u30b7\u30fc\u30f3\u756a\u53f7\u306e\u6570\u5b57\u3092\u6587\u5b57\u306b\u5909\u63db\r\n\r\n\t\t\/\/\u8a18\u9332\u3059\u308b\u6e96\u5099\r\n\t\tmyData jdata = new myData ();\r\n\t\tint i = 0;\r\n\t\t\/\/goList\u306e\u4e2d\u8eab\u3092JSON\u306b\u3059\u308bforeach\r\n\t\tforeach (var n in goList) {\r\n\r\n\t\tjdata.id = i;\r\n\t\t\tjdata.name = n.name;\r\n\t\t\tjdata.posx = n.transform.position.x;\r\n\tjdata.posy = n.transform.position.y;\r\n\tjdata.posz = n.transform.position.z;\r\n\tjdata.time = i * 10;\/\/dummy data\r\n\r\n\t\tstring json = JsonUtility.ToJson (jdata);\/\/\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092JSON\u6587\u5b57\u5217\u306b\u5909\u66f4\r\n\t\t\/\/\tDebug.Log(n.name);\r\n\t\t\ttempList.Add (json);\/\/LIST\u306bJSON\u3092\u8ffd\u52a0\r\n\t\t\ti++;\r\n\t\t}\r\n\r\n\r\n\t\t\/\/timeList1\u306b\u66f8\u304d\u63db\u3048\u306a\u306e\u304b\u8ffd\u52a0\u306a\u306e\u304b\u30c1\u30a7\u30c3\u30af\r\n\r\n\t\tif (timeList1.ContainsKey(scenceNum ) )\/\/\u73fe\u5728\u306e\u30b7\u30fc\u30f3\u756a\u53f7\u304ctimeList1\u306b\u542b\u307e\u308c\u3066\u3044\u308b\u3068\u304d\r\n\t\t{\r\n\t\t\ttimeList1[ scenceNum ] = tempList;\/\/timeList1\u306escenceNum\u306e\u30ea\u30b9\u30c8\u3092\u5165\u308c\u66ff\u3048\r\n\t\t}\r\n\t\telse\r\n\t\t{\u3000\/\/\u73fe\u5728\u306e\u30b7\u30fc\u30f3\u756a\u53f7\u304ctimeList1\u306b\u542b\u307e\u308c\u3066\u3044\u306a\u3044\u3068\u304d\r\n\t\t\ttimeList1.Add( scenceNum , tempList );\/\/timeList1\u306b\u65b0\u898f\u8ffd\u52a0\r\n\t\t\t\/\/\u30b7\u30fc\u30f3\u304c\u5897\u3048\u305f\u306e\u3067\u73fe\u5728\u306e\u30b7\u30fc\u30f3\u3082\u8ffd\u52a0\r\n\t\t\tscenceNum++;\r\n\t\t}\r\n\r\n\r\n\t\t\/\/\u30dc\u30bf\u30f3\u95a2\u9023\u51e6\u7406\r\n\t\t\/\/\u73fe\u5728\u306e\u30b7\u30fc\u30f3\u756a\u53f7\u304c0\u3088\u308a\u5927\u304d\u3051\u308c\u3070\uff1c\u30dc\u30bf\u30f3\u8868\u793a\r\n\t\tif (scenceNum &gt; 1) {\r\n\t\t\tsubBtn.interactable = true;\r\n\t\t}\r\n\r\n\t\t\/\/\u73fe\u5728\u306e\u30b7\u30fc\u30f3\u756a\u53f7\u304ctimeList1\u3068\u540c\u3058\u306a\u3089\uff1e\u30dc\u30bf\u30f3\u96a0\u3059\r\n\t\tif (scenceNum == timeList1.Count) {\r\n\t\t\taddBtn.interactable = false;\r\n\t\t}\r\n\r\n\t\t\/\/\u73fe\u5728\u306e\u30b7\u30fc\u30f3\u756a\u53f7\u304ctimeList1\u3088\u308a\u5c0f\u3055\u3044\u306a\u3089\uff1e\u30dc\u30bf\u30f3\u8868\u793a\r\n\t\tif (scenceNum &lt; timeList1.Count) {\r\n\t\t\taddBtn.interactable = true;\r\n\t\t}\r\n\t\t\t\r\n\t\tscnNumInput.text = scenceNum.ToString ();\/\/\u30b7\u30fc\u30f3\u756a\u53f7\u306e\u6570\u5b57\u3092\u6587\u5b57\u306b\u5909\u63db\u3057\u8868\u793a\r\n\t}\r\n\r\n\r\n\r\n\t\/\/\u30b7\u30fc\u30f3\u756a\u53f7\u6b21\u3078\u30dc\u30bf\u30f3\r\n\tpublic void  scnNumAdd(){\r\n\t\t\/\/\u73fe\u5728\u306e\u30b7\u30fc\u30f3\u756a\u53f7\u3092\uff11\u8db3\u3059\r\n\t\tscenceNum++;\r\n\r\n\t\t\/\/\u30b7\u30fc\u30f3\u756a\u53f7\u3092InputFileld\u306b\u8868\u793a\u66f8\u304d\u63db\u3048\r\n\t\tscnNumInput.text = scenceNum.ToString ();\r\n\r\n\t\t\/\/\u73fe\u5728\u306e\u30b7\u30fc\u30f3\u756a\u53f7\u304c0\u3088\u308a\u5927\u304d\u3051\u308c\u3070\uff1c\u30dc\u30bf\u30f3\u8868\u793a\r\n\t\tif (scenceNum &gt; 1) {\r\n\t\t\tsubBtn.interactable = true;\r\n\t\t}\r\n\r\n\t\t\/\/\u73fe\u5728\u306e\u30b7\u30fc\u30f3\u756a\u53f7\u304ctimeList1\u3088\u308a\u5927\u304d\u3051\u308c\u3070\uff1e\u30dc\u30bf\u30f3\u96a0\u3059\r\n\t\tif (scenceNum &gt;= timeList1.Count) {\r\n\t\t\taddBtn.interactable = false;\r\n\t\t}\r\n\t}\r\n\t\t\r\n\r\n\t\/\/\u30b7\u30fc\u30f3\u756a\u53f7\u623b\u308b\u30dc\u30bf\u30f3\r\n\tpublic void scnNumSub(){\r\n\t\t\/\/\u73fe\u5728\u306e\u30b7\u30fc\u30f3\u756a\u53f7\u3092\uff11\u6e1b\u3089\u3059\r\n\t\tscenceNum--;\r\n\r\n\t\t\/\/\u30b7\u30fc\u30f3\u756a\u53f7\u3092InputFileld\u306b\u8868\u793a\u66f8\u304d\u63db\u3048\r\n\t\tscnNumInput.text = scenceNum.ToString ();\r\n\r\n\t\t\/\/\u73fe\u5728\u306e\u30b7\u30fc\u30f3\u756a\u53f7\u304c0\u4ee5\u4e0b\u3067\u3042\u308c\u3070\uff1c\u30dc\u30bf\u30f3\u96a0\u3059\r\n\t\tif (scenceNum &lt;= 1) {\r\n\t\t\tsubBtn.interactable = false;\r\n\t\t}\r\n\r\n\t\t\/\/\u73fe\u5728\u306e\u30b7\u30fc\u30f3\u756a\u53f7\u304ctimeList1\u3088\u308a\u5c0f\u3055\u3051\u308c\u3070\uff1e\u30dc\u30bf\u30f3\u8868\u793a\r\n\t\tif (scenceNum &lt; timeList1.Count) {\r\n\t\t\taddBtn.interactable = true;\r\n\t\t}\r\n\r\n\t}\r\n\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<pre class=\"lang:default decode:true \" title=\"myData.cs\">[System.Serializable]\r\npublic class myData {\r\n\tpublic int id;\r\n\tpublic string name;\r\n\tpublic int time;\r\n\tpublic float posx;\r\n\tpublic float posy;\r\n\tpublic float posz;\r\n\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u914d\u7f6e\u78ba\u8a8d\uff08\u672a\u5b8c\u6210\uff092017\/10\/25\u3000AM11\u6642\u5909\u66f4 using System.Collections; using System.Collections.Generic; using UnityEngine; usi &hellip; <a href=\"https:\/\/nantoka.filmm.info\/blog\/?p=2571\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">\u914d\u7f6e\u78ba\u8a8d<\/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":[13,2],"tags":[],"class_list":["post-2571","post","type-post","status-publish","format-standard","hentry","category-c","category-unity"],"_links":{"self":[{"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2571","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=2571"}],"version-history":[{"count":6,"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2571\/revisions"}],"predecessor-version":[{"id":2577,"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2571\/revisions\/2577"}],"wp:attachment":[{"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2571"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2571"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2571"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}