{"id":2007,"date":"2017-08-04T00:15:24","date_gmt":"2017-08-03T15:15:24","guid":{"rendered":"http:\/\/blog.4star.link\/?p=2007"},"modified":"2017-08-04T00:15:24","modified_gmt":"2017-08-03T15:15:24","slug":"unity-ngui-%e3%81%ae-%e3%80%8cui-button%e3%80%8d%e3%81%aeonclick%e3%82%a4%e3%83%99%e3%83%b3%e3%83%88%e3%82%92%e3%82%b9%e3%82%af%e3%83%aa%e3%83%97%e3%83%88%e3%81%a7%e7%99%bb%e9%8c%b2%e3%81%99","status":"publish","type":"post","link":"https:\/\/blog.4star.link\/?p=2007","title":{"rendered":"Unity + NGUI \u306e \u300cUI Button\u300d\u306eOnClick\u30a4\u30d9\u30f3\u30c8\u3092\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u767b\u9332\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"<h3>\u30bf\u30a4\u30c8\u30eb\u306e\u901a\u308a\u3001Unity\u306e<strong>NGUI<\/strong>\u3067\u3001\u300cUI Button\u300d\u306eOnClick\u30a4\u30d9\u30f3\u30c8\u3092\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u767b\u9332\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066<\/h3>\n<p><a href=\"http:\/\/blog.4star.link\/wp-content\/uploads\/2017\/08\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2017-08-03-23.49.27.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.4star.link\/wp-content\/uploads\/2017\/08\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2017-08-03-23.49.27-266x300.png\" alt=\"\" width=\"266\" height=\"300\" class=\"aligncenter size-medium wp-image-2009\" srcset=\"https:\/\/blog.4star.link\/wp-content\/uploads\/2017\/08\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2017-08-03-23.49.27-266x300.png 266w, https:\/\/blog.4star.link\/wp-content\/uploads\/2017\/08\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2017-08-03-23.49.27.png 566w\" sizes=\"(max-width: 266px) 100vw, 266px\" \/><\/a><\/p>\n<p><strong>NGUI<\/strong>\u306e\u4fbf\u5229\u306a<strong>UIButton<\/strong>\u3067\u3059\u304c\u3001<br \/>\n\u30b9\u30af\u30ea\u30d7\u30c8\u3067<strong>OnClick<\/strong>\u306e\u30a4\u30d9\u30f3\u30c8\u3092\u767b\u9332\u3057\u305f\u4e8b\u304c\u306a\u304b\u3063\u305f\u3067\u3059\u304c\u3001<br \/>\n\u8272\u3005\u3057\u3089\u3079\u305f\u3068\u3053\u308d\u3084\u308a\u65b9\u304c\u5206\u304b\u3063\u305f\u306e\u3067\u30e1\u30e2\u3057\u307e\u3059\uff01<\/p>\n<p>\u4e0b\u8a18\u304c\u305d\u306e\u30bd\u30fc\u30b9\u3002<\/p>\n<p>GameManager.cs<\/p>\n<pre><code><br \/>\/\/ \u30a4\u30d9\u30f3\u30c8\u3092\u767b\u9332\u3057\u305f\u3044\u30dc\u30bf\u30f3\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\nGameObject btnObj;\n\n\/\/ NGUI\u306eUI Button\nUIButton btn = btnObj.GetComponent&lt;UIButton&gt;();\n\n\/\/ \u30a4\u30d9\u30f3\u30c8\u30c7\u30ea\u30b2\u30fc\u30c8\u3092\u7528\u610f\nEventDelegate btnEvent = new EventDelegate();\n\n\/\/ \u3053\u306e\u30af\u30e9\u30b9\u306eOnClick\u3068\u3044\u3046\u30e1\u30bd\u30c3\u30c9\nbtnEvent.Set(this,\"OnClick\");\n\n\/\/ \u540c\u3058\u30a4\u30d9\u30f3\u30c8\u304c\u8907\u6570\u5165\u3063\u3066\u3057\u307e\u3046\u3053\u3068\u3092\u907f\u3051\u308b\u305f\u3081\u4e00\u65e6\u30a4\u30d9\u30f3\u30c8\u3092\u30af\u30ea\u30a2\nbtn.onClick.Clear();\n\n\/\/ \u30a4\u30d9\u30f3\u30c8\u3092\u8ffd\u52a0\nbtn.onClick.Add(btnEvent);\n\n\/\/ NGUI\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u5b50\u3068\u3057\u3066\u8ffd\u52a0 \nNGUITools.AddChild (nguiParentObj, btnObj);\n\n<\/code><\/pre>\n<p>\u4ee5\u4e0a\u3067\u3059\uff01<\/p>\n<p>\u307e\u305f\u3001<\/p>\n<p><strong>btn.onClick.Clear();<\/strong><\/p>\n<p>\u306f\u3001Unity\u30a8\u30c7\u30a3\u30bf\u4e0a\u3067\u4f55\u56de\u3082\u5b9f\u884c\u306a\u3069\u3057\u3066\u3044\u308b\u3068\u3001<br \/>\n\u30a4\u30d9\u30f3\u30c8\u304c\u3069\u3093\u3069\u3093\u5897\u3048\u3066\u3057\u307e\u3046\u306e\u3067\u3001\u5ff5\u306e\u305f\u3081\u30ea\u30bb\u30c3\u30c8\u3057\u307e\u3059\u3002<br \/>\n\u3053\u3053\u3089\u3078\u3093\u306f\u74b0\u5883\u306b\u3042\u308f\u305b\u3066\u9069\u5b9c\u8abf\u6574\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u30b0\u30b0\u3063\u305f\u3093\u3067\u3059\u304c\u3001\u65e5\u672c\u8a9e\u306e\u60c5\u5831\u304c\u306a\u304b\u3063\u305f\u306e\u3067\u3001<br \/>\n\u5099\u5fd8\u9332\u306e\u305f\u3081\u30e1\u30e2\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30bf\u30a4\u30c8\u30eb\u306e\u901a\u308a\u3001Unity\u306eNGUI\u3067\u3001\u300cUI Button\u300d\u306eOnClick\u30a4\u30d9\u30f3\u30c8\u3092\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u767b\u9332\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066 NGUI\u306e\u4fbf\u5229\u306aUIButton\u3067\u3059\u304c\u3001 \u30b9\u30af\u30ea\u30d7\u30c8\u3067OnClick\u306e\u30a4\u30d9\u30f3\u30c8\u3092\u767b\u9332\u3057\u305f\u4e8b\u304c\u306a\u304b\u3063 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.4star.link\/?p=2007\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Unity + NGUI \u306e \u300cUI Button\u300d\u306eOnClick\u30a4\u30d9\u30f3\u30c8\u3092\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u767b\u9332\u3059\u308b\u65b9\u6cd5&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":2009,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16,265,234,255],"tags":[293,9,251],"class_list":["post-2007","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-android","category-ios","category-234","category-255","tag-ngui","tag-unity","tag-unity5"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/blog.4star.link\/index.php?rest_route=\/wp\/v2\/posts\/2007"}],"collection":[{"href":"https:\/\/blog.4star.link\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.4star.link\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.4star.link\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.4star.link\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2007"}],"version-history":[{"count":7,"href":"https:\/\/blog.4star.link\/index.php?rest_route=\/wp\/v2\/posts\/2007\/revisions"}],"predecessor-version":[{"id":2016,"href":"https:\/\/blog.4star.link\/index.php?rest_route=\/wp\/v2\/posts\/2007\/revisions\/2016"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.4star.link\/index.php?rest_route=\/wp\/v2\/media\/2009"}],"wp:attachment":[{"href":"https:\/\/blog.4star.link\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2007"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.4star.link\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2007"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.4star.link\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2007"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}