{"id":6552,"date":"2015-04-12T23:16:41","date_gmt":"2015-04-12T14:16:41","guid":{"rendered":"http:\/\/nanoappli.com\/blog\/?p=6552"},"modified":"2015-04-12T23:52:08","modified_gmt":"2015-04-12T14:52:08","slug":"unityugui%e3%81%a7%e3%80%81%e3%83%9c%e3%82%bf%e3%83%b3%e3%81%ae%e3%82%af%e3%83%aa%e3%83%83%e3%82%af%e3%82%a4%e3%83%99%e3%83%b3%e3%83%88%e3%82%92%e8%87%aa%e5%8b%95%e3%81%a7%e3%82%bb%e3%83%83%e3%83%88","status":"publish","type":"post","link":"http:\/\/nanoappli.com\/blog\/archives\/6552","title":{"rendered":"[Unity]uGUI\u3067\u3001\u30dc\u30bf\u30f3\u306e\u30af\u30ea\u30c3\u30af\u30a4\u30d9\u30f3\u30c8\u3092\u81ea\u52d5\u3067\u30bb\u30c3\u30c8\u3059\u308b\u3002"},"content":{"rendered":"<p>\nUnity\u306euGUI\u3092\u4f7f\u7528\u3057\u3066\u30dc\u30bf\u30f3\u3092\u4f5c\u308b\u5834\u5408\u3001Unity\u306e\u30a4\u30f3\u30b9\u30da\u30af\u30bf\u3067\u8a2d\u5b9a\u3059\u308b\u304b\u3001\u3082\u3057\u304f\u306f\u30dc\u30bf\u30f3\u306eonClick.AddListener()\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3057\u3066\u30a4\u30d9\u30f3\u30c8\u30cf\u30f3\u30c9\u30e9\u306e\u767b\u9332\u304c\u5fc5\u8981\u3067\u3059\u3002<br \/>\n<br \/>\n\u753b\u9762\u4e2d\u306b\u5b58\u5728\u3059\u308b\u30dc\u30bf\u30f3\u304c\u5c11\u306a\u3044\u5834\u5408\u306f\u3053\u306e\u65b9\u6cd5\u3067\u554f\u984c\u306a\u3044\u306e\u3067\u3059\u304c\u3001<br \/>\n\u30dc\u30bf\u30f3\u306e\u6570\u304c\u591a\u304f\u306a\u3063\u3066\u304f\u308b\u3068\u3053\u306e\u4f5c\u696d\u304c\u5927\u5909\u306b\u306a\u3063\u3066\u304d\u307e\u3059\u3002<br \/>\n<br \/>\n\u3053\u306e\u3088\u3046\u306a\u5834\u5408\u306f\u3001\u30ea\u30d5\u30ec\u30af\u30b7\u30e7\u30f3\u30af\u30e9\u30b9\u3092\u4f7f\u3046\u3068\u3001<br \/>\n\u540d\u524d\u5408\u308f\u305b\u3067\u30a4\u30d9\u30f3\u30c8\u30cf\u30f3\u30c9\u30e9\u3092\u81ea\u52d5\u767b\u9332\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br \/>\n<br \/>\n\u4e0b\u8a18\u306e\u30b3\u30fc\u30c9\u3092\u4f7f\u7528\u3059\u308b\u3068\u3001\u4f8b\u3048\u3070\u4e0b\u8a18\u306e\u5834\u5408\u306bbtnStart\u306eOnClick\u30a4\u30d9\u30f3\u30c8\u3068\u3057\u3066btnStart_Onclick()\u3092\u5272\u308a\u5f53\u3066\u3066\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br \/>\n1.Hierarchy\u4e0a\u306b&#8221;btnStart&#8221;\u3068\u3044\u3046\u540d\u524d\u3092\u6301\u3064uGUI\u306e\u30dc\u30bf\u30f3\u304c\u3042\u308b\u3002<br \/>\n2.\u672c\u30b9\u30af\u30ea\u30d7\u30c8\u4e0a\u306bbtnStart_Onclick()\u30e1\u30bd\u30c3\u30c9\u304c\u3042\u308b\u3002<br \/>\n<br \/>\n<br \/>\n\u3053\u308c\u3067\u3001\u9762\u5012\u306a\u30cf\u30f3\u30c9\u30e9\u306e\u767b\u9332\u3092\u624b\u52d5\u3067\u884c\u3046\u5fc5\u8981\u304c\u306a\u304f\u52b9\u7387\u3088\u304f\u958b\u767a\u3092\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br \/>\n<br \/>\n<pre lang=\"csharp\">\nusing UnityEngine;\nusing UnityEngine.UI;\nusing System.Collections;\nusing System.Reflection;\n\npublic class MainSceneScript : MonoBehaviour {\n    \n    void Start () {\n        \/\/\u30dc\u30bf\u30f3\u304c\u30af\u30ea\u30c3\u30af\u3055\u308c\u305f\u3068\u304d\u306e\u30cf\u30f3\u30c9\u30e9\u3092\u767b\u9332\n        SetButtonClickHandler();\n    }\n\n    \/\/ Start\u30dc\u30bf\u30f3\u304c\u30af\u30ea\u30c3\u30af\u3055\u308c\u305f\u3068\u304d\u306e\u30cf\u30f3\u30c9\u30e9\n    public void BtnStart_OnClick() {\n        Debug.Log (\"BtnStart_OnClick\u304c\u30b3\u30fc\u30eb\u3055\u308c\u307e\u3057\u305f\");\n    }\n\n    \/\/ \u89e3\u7b54\u30dc\u30bf\u30f3\u304c\u30af\u30ea\u30c3\u30af\u3055\u308c\u305f\u3068\u304d\u306e\u30cf\u30f3\u30c9\u30e9\n    public void BtnAnswer_OnClick() {\n        Debug.Log (\"BtnAnswer_OnClick\u304c\u30b3\u30fc\u30eb\u3055\u308c\u307e\u3057\u305f\");\n    }\n\n\n    \/\/\/ <summary>\n    \/\/\/ \u30dc\u30bf\u30f3\u306b\u30a4\u30d9\u30f3\u30c8\u30cf\u30f3\u30c9\u30e9\u3092\u5272\u308a\u5f53\u3066\u308b\u3002\n    \/\/\/ ex:Hierarchy\u4e0a\u306b\"btnStart\"\u3068\u3044\u3046\u540d\u524d\u3092\u6301\u3064uGUI\u306e\u30dc\u30bf\u30f3\u304c\u3042\u308a\u3001\n    \/\/\/    \u304b\u3064\u3001\u672c\u30b9\u30af\u30ea\u30d7\u30c8\u4e0a\u306bbtnStart_Onclick()\u30e1\u30bd\u30c3\u30c9\u304c\u3042\u308b\u5834\u5408\u3001\n    \/\/\/    btnStart\u306eOnClick\u30a4\u30d9\u30f3\u30c8\u3068\u3057\u3066btnStart_Onclick()\u3092\u5272\u308a\u5f53\u3066\u308b\u3002\n    \/\/\/ <\/summary>\n    private void SetButtonClickHandler() {\n\n        \/\/ \u30dc\u30bf\u30f3\u4e00\u89a7\u3092\u53d6\u5f97\n        Button[] buttonList = FindObjectsOfType<Button>();\n\n        \/\/ \u30e1\u30bd\u30c3\u30c9\u4e00\u89a7\u3092\u53d6\u5f97\n        BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static;\n        MethodInfo[] methodList = this.GetType().GetMethods( flags );\n\n        \/\/ \u3059\u3079\u3066\u306e\u30dc\u30bf\u30f3\u306b\u30cf\u30f3\u30c9\u30e9\u3092\u767b\u9332\u3059\u308b\u307e\u3067\u7e70\u308a\u8fd4\u3057\n        foreach (Button curBtn in buttonList ) {\n            string searchMethodName = curBtn.name.ToUpper() + \"_ONCLICK\";\n\n            \/\/ \u30dc\u30bf\u30f3\u3078\u30a4\u30d9\u30f3\u30c8\u30cf\u30f3\u30c9\u30e9\u3092\u767b\u9332\u3059\u308b\n            MethodInfo handlerMethod = null;\n            foreach ( MethodInfo curMethod in methodList ) {\n                \/\/ \u30dc\u30bf\u30f3\u540d + \"_OnClick\"\u306e\u540d\u524d\u306e\u30e1\u30bd\u30c3\u30c9\u4ee5\u5916\u306fSkip\n                if ( curMethod.Name.ToUpper() != searchMethodName ) {\n                    continue;\n                }\n\n                \/\/ \u30dc\u30bf\u30f3\u30af\u30ea\u30c3\u30af\u6642\u306e\u30cf\u30f3\u30c9\u30e9\u3092\u767b\u9332\u3059\u308b\n                curBtn.onClick.AddListener( delegate { curMethod.Invoke( this, null ); } );\n                Debug.Log( \"\u30af\u30ea\u30c3\u30af\u306e\u30a4\u30d9\u30f3\u30c8\u30cf\u30f3\u30c9\u30e9\u3092\u767b\u9332\u3057\u307e\u3057\u305f name=\" + curBtn.name );\n                break;\n            }\n        }\n    }\n}\n<\/pre>\n<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Unity\u306euGUI\u3092\u4f7f\u7528\u3057\u3066\u30dc\u30bf\u30f3\u3092\u4f5c\u308b\u5834\u5408\u3001Unity\u306e\u30a4\u30f3\u30b9\u30da\u30af\u30bf\u3067\u8a2d\u5b9a\u3059\u308b\u304b\u3001\u3082\u3057\u304f\u306f\u30dc\u30bf\u30f3\u306eonClick.AddListener()\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3057\u3066\u30a4\u30d9\u30f3\u30c8\u30cf\u30f3\u30c9\u30e9\u306e\u767b\u9332\u304c\u5fc5\u8981\u3067\u3059\u3002 \u753b\u9762\u4e2d\u306b\u5b58\u5728\u3059\u308b\u30dc\u30bf\u30f3\u304c\u5c11\u306a\u3044\u5834\u5408\u306f\u3053\u306e\u65b9\u6cd5\u3067\u554f\u984c\u306a\u3044\u306e\u3067\u3059\u304c\u3001 \u30dc\u30bf\u30f3\u306e\u6570\u304c\u591a\u304f\u306a\u3063\u3066\u304f\u308b\u3068\u3053\u306e\u4f5c\u696d\u304c\u5927\u5909\u306b\u306a\u3063\u3066\u304d\u307e\u3059\u3002 \u3053\u306e\u3088\u3046\u306a\u5834\u5408\u306f\u3001\u30ea\u30d5\u30ec\u30af\u30b7\u30e7\u30f3\u30af\u30e9\u30b9\u3092\u4f7f\u3046\u3068\u3001 \u540d\u524d\u5408\u308f\u305b\u3067\u30a4\u30d9\u30f3\u30c8\u30cf\u30f3\u30c9\u30e9\u3092\u81ea\u52d5\u767b\u9332\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002 \u4e0b\u8a18\u306e\u30b3\u30fc\u30c9\u3092\u4f7f\u7528\u3059\u308b\u3068\u3001\u4f8b\u3048\u3070\u4e0b\u8a18\u306e\u5834\u5408\u306bbtnStart\u306eOnClick\u30a4\u30d9\u30f3\u30c8\u3068\u3057\u3066btnStart_Onclick()\u3092\u5272\u308a\u5f53\u3066\u3066\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002 1.Hi\u2026<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[185],"tags":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":6540,"url":"http:\/\/nanoappli.com\/blog\/archives\/6540","url_meta":{"origin":6552,"position":0},"title":"[Unity3D]uGUI\u3067\u30dc\u30bf\u30f3\u30af\u30ea\u30c3\u30af\u6642\u306e\u30cf\u30f3\u30c9\u30e9\u3092\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u767b\u9332\u3059\u308b","date":"2015\u5e744\u670812\u65e5","format":false,"excerpt":"Unity\u3067uGUI\u306e\u30dc\u30bf\u30f3\u30af\u30ea\u30c3\u30af\u306b\u5bfe\u3059\u308b\u30a4\u30d9\u30f3\u30c8\u30cf\u30f3\u30c9\u30e9\u3092\u767b\u9332\u3057\u305f\u3044\u6642\u306f\u3001 AddListene\u2026","rel":"","context":"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/nanoappli.com\/blog\/wp-content\/uploads\/2015\/04\/150412_1.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1431,"url":"http:\/\/nanoappli.com\/blog\/archives\/1431","url_meta":{"origin":6552,"position":1},"title":"[C#]\u30a2\u30d7\u30ea\u306e\u8a2d\u5b9a\u753b\u9762\u3067\u5165\u529b\u3057\u305f\u5185\u5bb9\u3092app.config\u3067\u7ba1\u7406\u3059\u308b","date":"2012\u5e742\u670824\u65e5","format":false,"excerpt":"\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u306f\u901a\u5e38\u3001\u300c\u30c4\u30fc\u30eb\u2192\u30aa\u30d7\u30b7\u30e7\u30f3\u300d\u7b49\u306e\u30e1\u30cb\u30e5\u30fc\u3067\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u52d5\u4f5c\u5185\u5bb9\u3092\u30e6\u30fc\u30b6\u304c\u30ab\u30b9\u30bf\u2026","rel":"","context":"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/nanoappli.com\/blog\/wp-content\/uploads\/2012\/02\/20120224_04.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":6327,"url":"http:\/\/nanoappli.com\/blog\/archives\/6327","url_meta":{"origin":6552,"position":2},"title":"[C#]Esc\u30ad\u30fc\u3092\u62bc\u3057\u305f\u3089\u30d5\u30a9\u30fc\u30e0\u3092\u30af\u30ed\u30fc\u30ba\u3055\u305b\u308b\u65b9\u6cd5","date":"2013\u5e744\u670823\u65e5","format":false,"excerpt":"C#(.NetFramework)\u3067\u3001Esc\u30ad\u30fc\u3092\u62bc\u3057\u305f\u3089\u30d5\u30a9\u30fc\u30e0\u3092\u30af\u30ed\u30fc\u30ba\u3055\u305b\u308b\u65b9\u6cd5\u3067\u3059\u3002 For\u2026","rel":"","context":"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":6833,"url":"http:\/\/nanoappli.com\/blog\/archives\/6833","url_meta":{"origin":6552,"position":3},"title":"[C#]Label\u306a\u3069GUI\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u306e\u52d5\u7684\u751f\u6210\u30b3\u30fc\u30c9\u3092\u4e00\u77ac\u3067\u4f5c\u308b\u65b9\u6cd5","date":"2016\u5e741\u670829\u65e5","format":false,"excerpt":"VisualStudio\u3067WinForm\u3092\u4f7f\u3063\u3066\u753b\u9762\u3092\u4f5c\u308b\u969b\u3001\u901a\u5e38\u306f\u30dc\u30bf\u30f3\u3084\u30c6\u30ad\u30b9\u30c8\u30dc\u30c3\u30af\u30b9\u306a\u3069\u306eG\u2026","rel":"","context":"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/nanoappli.com\/blog\/wp-content\/uploads\/2016\/01\/20160129_1-500x205.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":2781,"url":"http:\/\/nanoappli.com\/blog\/archives\/2781","url_meta":{"origin":6552,"position":4},"title":"[C#]WMI\u30a4\u30d9\u30f3\u30c8\u3092ManagementEventWatcher\u30af\u30e9\u30b9\u3067\u51e6\u7406\u3059\u308b","date":"2012\u5e745\u670824\u65e5","format":false,"excerpt":"Windows\u3067\u306f\u3001WMI(Windows Management Instrumentation)\u306e\u2026","rel":"","context":"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/nanoappli.com\/blog\/wp-content\/uploads\/2012\/05\/20120524_06.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1274,"url":"http:\/\/nanoappli.com\/blog\/archives\/1274","url_meta":{"origin":6552,"position":5},"title":"C#\u306e\u30e9\u30e0\u30c0\u5f0f\u3092\u30c1\u30a7\u30fc\u30f3\u3055\u305b\u308b\u8a18\u6cd5\u304c\u4fbf\u5229!","date":"2012\u5e742\u67089\u65e5","format":false,"excerpt":"(\u3053\u306e\u8a18\u4e8b\u306f,Hidden Features of C#?\u3092\u53c2\u8003\u306b\u8a18\u8ff0\u3057\u3066\u3044\u307e\u3059) C#\u3067\u306f\u3001\u30d0\u30fc\u30b8\u2026","rel":"","context":"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/nanoappli.com\/blog\/wp-json\/wp\/v2\/posts\/6552"}],"collection":[{"href":"http:\/\/nanoappli.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/nanoappli.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/nanoappli.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/nanoappli.com\/blog\/wp-json\/wp\/v2\/comments?post=6552"}],"version-history":[{"count":9,"href":"http:\/\/nanoappli.com\/blog\/wp-json\/wp\/v2\/posts\/6552\/revisions"}],"predecessor-version":[{"id":6563,"href":"http:\/\/nanoappli.com\/blog\/wp-json\/wp\/v2\/posts\/6552\/revisions\/6563"}],"wp:attachment":[{"href":"http:\/\/nanoappli.com\/blog\/wp-json\/wp\/v2\/media?parent=6552"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/nanoappli.com\/blog\/wp-json\/wp\/v2\/categories?post=6552"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/nanoappli.com\/blog\/wp-json\/wp\/v2\/tags?post=6552"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}