{"id":2511,"date":"2017-07-26T14:19:01","date_gmt":"2017-07-26T05:19:01","guid":{"rendered":"http:\/\/nantoka.filmm.info\/blog\/?p=2511"},"modified":"2017-07-26T14:22:55","modified_gmt":"2017-07-26T05:22:55","slug":"unity%e3%81%a7%e3%80%80dictionary","status":"publish","type":"post","link":"https:\/\/nantoka.filmm.info\/blog\/?p=2511","title":{"rendered":"Unity\u3067\u3000Dictionary"},"content":{"rendered":"<h3>Unity\u3067Dictionary\u3092\u4f7f\u3046\u6e96\u5099<\/h3>\n<pre class=\"lang:default decode:true \">using System.Collections.Generic;\/\/\u5fc5\u305a\u5fc5\u8981<\/pre>\n<p>\u4e0a\u306e\u65b9\u306eusing\u3042\u305f\u308a\u306b\u8ffd\u8a18<\/p>\n<hr \/>\n<h3>Dictionary\u3092\u5ba3\u8a00<\/h3>\n<pre class=\"lang:default decode:true \">Dictionary&lt;int, GameObject&gt; prefabDic;<\/pre>\n<p>prefabDic\u3068\u3044\u3046\u540d\u306eDictionary\u3092\u5ba3\u8a00<\/p>\n<hr \/>\n<h3>Dctionary\u3092\u521d\u671f\u5316\u307f\u305f\u3044\u306a\u306e<\/h3>\n<pre class=\"lang:default decode:true\">prefabDic = new Dictionary&lt;int, GameObject&gt; ();<\/pre>\n<p>\u3092void Start(){\u3000\u306e\u4e2d\u306b\u304b\u304f<\/p>\n<hr \/>\n<h3>\u30ad\u30e3\u30e9\u4f5c\u6210\u3057\u3064\u3064Dictionary\u306b\u767b\u9332<\/h3>\n<pre class=\"lang:default decode:true \">\t\/\/\u30ad\u30e3\u30e9\uff4e\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\tprefabDic.Add (i, go);\r\n\t\t}<\/pre>\n<p>i\u306fDictionary\u306e\u5de6\u5217\u306b\u3000\u3053\u306e\u5f8c\u3067\u547c\u3073\u51fa\u3059\u756a\u53f7\u306b\u3057\u3066\u3044\u308b<\/p>\n<p>go\u306f\u30b2\u30fc\u30e0\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u5165\u3063\u3066\u3044\u308b\u306e\u3067\uff0c<\/p>\n<p>prefabDic.Add(i, go);\u3067\u756a\u53f7\u3068\u30b2\u30fc\u30e0\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30bb\u30c3\u30c8\u3067Dictionary\u306b\u8ffd\u8a18(Add\uff09\u3055\u308c\u308b<\/p>\n<hr \/>\n<h3>dictionary\u306e3\u756a\u306e\u30b2\u30fc\u30e0\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u6d88\u3059<\/h3>\n<pre class=\"lang:default decode:true\">GameObject delobj = prefabDic [3];\r\n\t\tDestroy (delobj);<\/pre>\n<p>prefabDic[3]\u30673\u756a\u306e\u30b2\u30fc\u30e0\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u547c\u3073\u51fa\u3055\u308c\u308b\u306e\u3067\uff0c\u305d\u308c\u3092Destroy\u3057\u3066\u3044\u308b<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Unity\u3067Dictionary\u3092\u4f7f\u3046\u6e96\u5099 using System.Collections.Generic;\/\/\u5fc5\u305a\u5fc5\u8981 \u4e0a\u306e\u65b9\u306eusing\u3042\u305f\u308a\u306b\u8ffd\u8a18 Dictionary\u3092\u5ba3\u8a00 Dictionary&lt;int, &hellip; <a href=\"https:\/\/nantoka.filmm.info\/blog\/?p=2511\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">Unity\u3067\u3000Dictionary<\/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,48],"tags":[],"class_list":["post-2511","post","type-post","status-publish","format-standard","hentry","category-c","category-unity","category-48"],"_links":{"self":[{"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2511","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=2511"}],"version-history":[{"count":4,"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2511\/revisions"}],"predecessor-version":[{"id":2515,"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2511\/revisions\/2515"}],"wp:attachment":[{"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2511"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2511"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2511"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}