{"id":3363,"date":"2017-02-08T14:08:20","date_gmt":"2017-02-08T14:08:20","guid":{"rendered":"https:\/\/www.codebee.co.th\/labs\/?p=3363"},"modified":"2017-04-22T05:31:52","modified_gmt":"2017-04-22T05:31:52","slug":"%e0%b8%aa%e0%b8%ad%e0%b8%99-unity3d-c-%e0%b8%95%e0%b8%ad%e0%b8%99-4-%e0%b9%80%e0%b8%9e%e0%b8%b4%e0%b9%88%e0%b8%a1-event-onclick-%e0%b9%83%e0%b8%ab%e0%b9%89-ui-button","status":"publish","type":"post","link":"https:\/\/www.codebee.co.th\/labs\/%e0%b8%aa%e0%b8%ad%e0%b8%99-unity3d-c-%e0%b8%95%e0%b8%ad%e0%b8%99-4-%e0%b9%80%e0%b8%9e%e0%b8%b4%e0%b9%88%e0%b8%a1-event-onclick-%e0%b9%83%e0%b8%ab%e0%b9%89-ui-button\/","title":{"rendered":"\u0e2a\u0e2d\u0e19 Unity3D C# \u0e15\u0e2d\u0e19 4 \u0e40\u0e1e\u0e34\u0e48\u0e21 event onClick \u0e43\u0e2b\u0e49 UI Button"},"content":{"rendered":"<h3>\u0e2a\u0e2d\u0e19 Unity3D C# \u0e15\u0e2d\u0e19 4 \u0e40\u0e1e\u0e34\u0e48\u0e21 event onClick \u0e43\u0e2b\u0e49 UI Button<\/h3>\n<p><\/br><br \/>\n<strong>\u0e2a\u0e2d\u0e19 Unity3D C# \u0e15\u0e2d\u0e19 4 \u0e40\u0e1e\u0e34\u0e48\u0e21 event onClick \u0e43\u0e2b\u0e49 UI Button<\/strong><br \/>\n\u0e43\u0e19\u0e1a\u0e17\u0e04\u0e27\u0e32\u0e21\u0e17\u0e35\u0e48\u0e41\u0e25\u0e49\u0e27 \u0e40\u0e23\u0e32\u0e44\u0e14\u0e49\u0e40\u0e23\u0e34\u0e48\u0e21\u0e15\u0e49\u0e19\u0e14\u0e49\u0e27\u0e22\u0e01\u0e32\u0e23\u0e2a\u0e23\u0e49\u0e32\u0e07\u0e44\u0e1f\u0e25\u0e4c C# \u0e44\u0e1f\u0e25\u0e4c .cs \u0e43\u0e19 Unity \u0e41\u0e25\u0e30\u0e17\u0e14\u0e2a\u0e2d\u0e1a\u0e01\u0e32\u0e23\u0e17\u0e33\u0e07\u0e32\u0e19\u0e02\u0e2d\u0e07\u0e1f\u0e31\u0e07\u0e01\u0e4c\u0e0a\u0e31\u0e48\u0e19 void Start() \u0e41\u0e25\u0e30\u0e1f\u0e31\u0e07\u0e01\u0e4c\u0e0a\u0e31\u0e48\u0e19 void Update()<br \/>\n<\/br><br \/>\n\u0e43\u0e19\u0e1a\u0e17\u0e04\u0e27\u0e32\u0e21\u0e19\u0e35\u0e49\u0e40\u0e23\u0e32\u0e08\u0e30\u0e17\u0e14\u0e25\u0e2d\u0e07\u0e2a\u0e23\u0e49\u0e32\u0e07\u0e1f\u0e31\u0e07\u0e01\u0e4c\u0e0a\u0e31\u0e48\u0e19\u0e02\u0e36\u0e49\u0e19\u0e21\u0e32\u0e40\u0e2d\u0e07 \u0e41\u0e25\u0e30\u0e40\u0e23\u0e34\u0e48\u0e21\u0e01\u0e32\u0e23\u0e17\u0e33\u0e07\u0e32\u0e19\u0e02\u0e2d\u0e07\u0e1f\u0e31\u0e07\u0e01\u0e4c\u0e0a\u0e31\u0e48\u0e19\u0e40\u0e21\u0e37\u0e48\u0e2d\u0e21\u0e35\u0e01\u0e32\u0e23\u0e04\u0e25\u0e34\u0e01\u0e17\u0e35\u0e48\u0e1b\u0e38\u0e48\u0e21 \u0e2b\u0e23\u0e37\u0e2d UI Button \u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e14\u0e49\u0e32\u0e19\u0e25\u0e48\u0e32\u0e07 \u0e16\u0e49\u0e32\u0e44\u0e21\u0e48\u0e40\u0e02\u0e49\u0e32\u0e43\u0e08\u0e43\u0e2b\u0e49\u0e01\u0e25\u0e31\u0e1a\u0e44\u0e1b\u0e2d\u0e48\u0e32\u0e19\u0e1a\u0e17\u0e04\u0e27\u0e32\u0e21\u0e01\u0e48\u0e2d\u0e19\u0e19\u0e2b\u0e19\u0e49\u0e32\u0e19\u0e35\u0e49 <a href=\"https:\/\/www.codebee.co.th\/labs\/\u0e2a\u0e2d\u0e19-unity3d-c-\u0e15\u0e2d\u0e19-3-\u0e2a\u0e23\u0e49\u0e32\u0e07\u0e44\u0e1f\u0e25\u0e4c\u0e20\u0e32\u0e29\u0e32-c-\u0e41\/\" target=\"_blank\">https:\/\/www.codebee.co.th\/labs\/\u0e2a\u0e2d\u0e19-unity3d-c-\u0e15\u0e2d\u0e19-3-\u0e2a\u0e23\u0e49\u0e32\u0e07\u0e44\u0e1f\u0e25\u0e4c\u0e20\u0e32\u0e29\u0e32-c-\u0e41\/<\/a><!--more--><\/p>\n<p><\/br><\/p>\n<h4>\u0e23\u0e31\u0e1a event onClick \u0e40\u0e21\u0e37\u0e48\u0e2d\u0e21\u0e35\u0e01\u0e32\u0e23\u0e04\u0e25\u0e34\u0e01\u0e17\u0e35\u0e48\u0e1b\u0e38\u0e48\u0e21<\/h4>\n<p>1. \u0e43\u0e19\u0e2b\u0e19\u0e49\u0e32\u0e15\u0e48\u0e32\u0e07 hierarchy \u0e2a\u0e23\u0e49\u0e32\u0e07 Empty Object \u0e41\u0e25\u0e30\u0e15\u0e31\u0e49\u0e07\u0e0a\u0e37\u0e48\u0e2d\u0e43\u0e2b\u0e21\u0e48\u0e27\u0e48\u0e32 AppController<br \/>\n2. \u0e43\u0e19\u0e2b\u0e19\u0e49\u0e32\u0e15\u0e48\u0e32\u0e07 Assets \u0e2a\u0e23\u0e49\u0e32\u0e07\u0e42\u0e1f\u0e25\u0e40\u0e14\u0e49\u0e2d\u0e15\u0e31\u0e49\u0e07\u0e0a\u0e37\u0e48\u0e2d\u0e27\u0e48\u0e32 script \u0e41\u0e25\u0e30\u0e43\u0e19\u0e42\u0e1f\u0e25\u0e40\u0e14\u0e49\u0e2d script \u0e2a\u0e23\u0e49\u0e32\u0e07\u0e44\u0e1f\u0e25\u0e4c .cs \u0e15\u0e31\u0e49\u0e07\u0e0a\u0e37\u0e48\u0e2d\u0e27\u0e48\u0e32 AppController.cs<br \/>\n3. \u0e25\u0e32\u0e01\u0e44\u0e1f\u0e25\u0e4c AppController.cs \u0e44\u0e1b\u0e27\u0e32\u0e07\u0e44\u0e27\u0e49\u0e43\u0e19 Object AppController \u0e08\u0e32\u0e01\u0e19\u0e31\u0e49\u0e19\u0e40\u0e1b\u0e34\u0e14\u0e44\u0e1f\u0e25\u0e4c AppController.cs \u0e41\u0e25\u0e30\u0e40\u0e02\u0e35\u0e22\u0e19\u0e42\u0e04\u0e4a\u0e14\u0e14\u0e31\u0e07\u0e19\u0e35\u0e49<\/p>\n<pre class=\"lang:default decode:true \" >using UnityEngine;\r\nusing System.Collections;\r\nusing UnityEngine.UI; \/\/ \u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e43\u0e2b\u0e49\u0e43\u0e0a\u0e49\u0e07\u0e32\u0e19 UI Component \u0e02\u0e2d\u0e07 Unity \u0e44\u0e14\u0e49\r\n\r\npublic class AppController : MonoBehaviour {\r\n\r\n\tpublic Button startBtn; \/\/ \u0e2a\u0e23\u0e49\u0e32\u0e07\u0e15\u0e31\u0e27\u0e41\u0e1b\u0e23\u0e41\u0e1a\u0e1a public \u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e43\u0e2b\u0e49 workspace \u0e02\u0e2d\u0e07 unity \u0e40\u0e02\u0e49\u0e32\u0e16\u0e36\u0e07\u0e41\u0e1b\u0e23\u0e19\u0e35\u0e49\u0e44\u0e14\u0e49\r\n\r\n\tvoid Start () {\r\n\t\tDebug.Log (\"Start\");\r\n\t}\r\n\tvoid Update () {\r\n\t\tDebug.Log (\"Update\");\r\n\t}\r\n}<\/pre>\n<p>4. \u0e2b\u0e25\u0e31\u0e07\u0e08\u0e32\u0e01\u0e17\u0e35\u0e48\u0e40\u0e23\u0e32\u0e41\u0e01\u0e49\u0e44\u0e02\u0e44\u0e1f\u0e25\u0e4c AppController.cs \u0e40\u0e23\u0e35\u0e22\u0e1a\u0e23\u0e49\u0e2d\u0e22\u0e41\u0e25\u0e49\u0e27 \u0e40\u0e1b\u0e25\u0e35\u0e48\u0e22\u0e19\u0e21\u0e32\u0e17\u0e33\u0e07\u0e32\u0e19\u0e17\u0e35\u0e48 workspace \u0e02\u0e2d\u0e07 unity \u0e40\u0e25\u0e37\u0e2d\u0e01\u0e44\u0e1b\u0e17\u0e35\u0e48 AppController Object \u0e43\u0e19\u0e2b\u0e19\u0e49\u0e32\u0e15\u0e48\u0e32\u0e07 inspector \u0e08\u0e30\u0e1b\u0e23\u0e32\u0e01\u0e0f input \u0e17\u0e35\u0e48\u0e0a\u0e37\u0e48\u0e2d\u0e27\u0e48\u0e32 Start Btn \u0e15\u0e32\u0e21\u0e0a\u0e37\u0e48\u0e2d\u0e15\u0e31\u0e27\u0e41\u0e1b\u0e23\u0e41\u0e1a\u0e1a public \u0e17\u0e35\u0e48\u0e40\u0e23\u0e32\u0e44\u0e14\u0e49\u0e2a\u0e23\u0e49\u0e32\u0e07\u0e44\u0e27\u0e49\u0e43\u0e19\u0e02\u0e31\u0e49\u0e19\u0e15\u0e2d\u0e19\u0e17\u0e35\u0e48 3 \u0e43\u0e2b\u0e49\u0e25\u0e32\u0e01\u0e1b\u0e38\u0e48\u0e21\u0e17\u0e35\u0e48\u0e40\u0e23\u0e32\u0e44\u0e14\u0e49\u0e2a\u0e23\u0e49\u0e32\u0e07\u0e44\u0e27\u0e49\u0e43\u0e19\u0e2a\u0e48\u0e27\u0e19\u0e02\u0e2d\u0e07 hierarchy \u0e21\u0e32\u0e27\u0e32\u0e07\u0e44\u0e27\u0e49\u0e43\u0e19\u0e0a\u0e48\u0e2d\u0e07\u0e19\u0e35\u0e49<br \/>\n<\/br><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.codebee.co.th\/labs\/wp-content\/uploads\/2017\/02\/\u0e2a\u0e2d\u0e19-unity3d-\u0e04\u0e25\u0e34\u0e01-1.png\" alt=\"\u0e2a\u0e2d\u0e19-unity3d-\u0e04\u0e25\u0e34\u0e01\" \/><br \/>\n<\/br><br \/>\n5. \u0e40\u0e21\u0e37\u0e48\u0e2d\u0e1c\u0e48\u0e32\u0e19\u0e02\u0e31\u0e49\u0e19\u0e15\u0e2d\u0e19\u0e17\u0e35\u0e48 4 \u0e40\u0e23\u0e35\u0e22\u0e1a\u0e23\u0e49\u0e2d\u0e22\u0e41\u0e25\u0e49\u0e27 \u0e1b\u0e38\u0e48\u0e21\u0e43\u0e19 workspace \u0e08\u0e30\u0e21\u0e35\u0e04\u0e48\u0e32\u0e41\u0e25\u0e30\u0e40\u0e1b\u0e47\u0e19\u0e15\u0e31\u0e27\u0e40\u0e14\u0e35\u0e22\u0e27\u0e01\u0e31\u0e19\u0e01\u0e31\u0e1a\u0e15\u0e31\u0e27\u0e41\u0e1b\u0e23 startBtn \u0e17\u0e35\u0e48\u0e40\u0e23\u0e32\u0e1b\u0e23\u0e30\u0e01\u0e32\u0e28\u0e44\u0e27\u0e49\u0e43\u0e19\u0e44\u0e1f\u0e25\u0e4c AppController.cs \u0e43\u0e2b\u0e49\u0e40\u0e1b\u0e34\u0e14\u0e44\u0e1f\u0e25\u0e4c AppController.cs \u0e40\u0e02\u0e35\u0e22\u0e19\u0e04\u0e33\u0e2a\u0e31\u0e48\u0e07\u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e43\u0e2b\u0e49\u0e1b\u0e38\u0e48\u0e21\u0e21\u0e35 event \u0e15\u0e2d\u0e19\u0e04\u0e25\u0e34\u0e01\u0e14\u0e31\u0e07\u0e19\u0e35\u0e49<\/p>\n<pre class=\"lang:default decode:true \" >\r\nusing UnityEngine;\r\nusing System.Collections;\r\nusing UnityEngine.UI; \/\/ \u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e43\u0e2b\u0e49\u0e43\u0e0a\u0e49\u0e07\u0e32\u0e19 UI Component \u0e02\u0e2d\u0e07 Unity \u0e44\u0e14\u0e49\r\n\r\npublic class AppController : MonoBehaviour {\r\n\r\n\tpublic Button startBtn; \/\/ \u0e2a\u0e23\u0e49\u0e32\u0e07\u0e15\u0e31\u0e27\u0e41\u0e1b\u0e23\u0e41\u0e1a\u0e1a public \u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e43\u0e2b\u0e49 workspace \u0e02\u0e2d\u0e07 unity \u0e40\u0e02\u0e49\u0e32\u0e16\u0e36\u0e07\u0e41\u0e1b\u0e23\u0e19\u0e35\u0e49\u0e44\u0e14\u0e49\r\n\r\n\tvoid Start () {\r\n\t\tstartBtn.onClick.AddListener(delegate(){\r\n\t\t\tstartGame();\r\n\t\t});\r\n\t}\r\n\tvoid startGame(){\r\n\t\tDebug.Log (\"on Click Start Game !!!\");\r\n\t}\r\n\tvoid Update () {\r\n\t\t\r\n\t}\r\n}<\/pre>\n<p>6. \u0e17\u0e14\u0e2a\u0e2d\u0e1a\u0e01\u0e32\u0e23\u0e17\u0e33\u0e07\u0e32\u0e19 \u0e42\u0e14\u0e22\u0e01\u0e14\u0e1b\u0e38\u0e48\u0e21 Play \u0e43\u0e19\u0e2b\u0e19\u0e49\u0e32 workspace \u0e02\u0e2d\u0e07 Unity \u0e17\u0e14\u0e25\u0e2d\u0e07\u0e01\u0e14\u0e1b\u0e38\u0e48\u0e21\u0e41\u0e25\u0e30\u0e14\u0e39\u0e1c\u0e25\u0e25\u0e31\u0e1e\u0e18\u0e4c\u0e43\u0e19\u0e2b\u0e19\u0e49\u0e32 Console \u0e08\u0e30\u0e40\u0e2b\u0e47\u0e19\u0e27\u0e48\u0e32 \u0e17\u0e38\u0e01\u0e04\u0e23\u0e31\u0e49\u0e07\u0e17\u0e35\u0e48\u0e01\u0e14\u0e1b\u0e38\u0e48\u0e21\u0e15\u0e31\u0e27\u0e41\u0e2d\u0e1e\u0e08\u0e30\u0e27\u0e34\u0e48\u0e07\u0e44\u0e1b\u0e17\u0e33\u0e07\u0e32\u0e19\u0e17\u0e35\u0e48\u0e1f\u0e31\u0e07\u0e01\u0e4c\u0e0a\u0e31\u0e48\u0e19 startGame() \u0e17\u0e35\u0e48\u0e40\u0e23\u0e32\u0e44\u0e14\u0e49\u0e40\u0e02\u0e35\u0e22\u0e19\u0e44\u0e27\u0e49\u0e43\u0e19 AppController.cs<br \/>\n<\/br><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.codebee.co.th\/labs\/wp-content\/uploads\/2017\/02\/\u0e2a\u0e2d\u0e19-unity3d-\u0e04\u0e25\u0e34\u0e01-2.png\" alt=\"\u0e2a\u0e2d\u0e19-unity3d-\u0e04\u0e25\u0e34\u0e01\" \/><br \/>\n<\/br><br \/>\n<\/br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0e2a\u0e2d\u0e19 Unity3D C# \u0e15\u0e2d\u0e19 4 \u0e40\u0e1e\u0e34\u0e48\u0e21 event onClick \u0e43\u0e2b\u0e49 UI Button \u0e2a\u0e2d\u0e19 Unity3D C# \u0e15\u0e2d\u0e19 4 \u0e40\u0e1e\u0e34\u0e48\u0e21 event onClick \u0e43\u0e2b\u0e49&#8230;<\/p>\n","protected":false},"author":1,"featured_media":2501,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"video","meta":{"footnotes":""},"categories":[45,1222],"tags":[1229,1227,1228,864,836,996,1224,1231,1230,1002],"class_list":{"0":"post-3363","1":"post","2":"type-post","3":"status-publish","4":"format-video","5":"has-post-thumbnail","6":"hentry","7":"category-mobile-development-","8":"category-unity3d-development","9":"tag-c-event-onclick","10":"tag-ui-button-unity-onclick","11":"tag-unity-","12":"tag-864","13":"tag--unity3d","14":"tag-996","15":"tag--c","18":"tag-1002","19":"post_format-post-format-video"},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.codebee.co.th\/labs\/wp-json\/wp\/v2\/posts\/3363","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codebee.co.th\/labs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codebee.co.th\/labs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codebee.co.th\/labs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codebee.co.th\/labs\/wp-json\/wp\/v2\/comments?post=3363"}],"version-history":[{"count":4,"href":"https:\/\/www.codebee.co.th\/labs\/wp-json\/wp\/v2\/posts\/3363\/revisions"}],"predecessor-version":[{"id":3369,"href":"https:\/\/www.codebee.co.th\/labs\/wp-json\/wp\/v2\/posts\/3363\/revisions\/3369"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.codebee.co.th\/labs\/wp-json\/wp\/v2\/media\/2501"}],"wp:attachment":[{"href":"https:\/\/www.codebee.co.th\/labs\/wp-json\/wp\/v2\/media?parent=3363"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codebee.co.th\/labs\/wp-json\/wp\/v2\/categories?post=3363"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codebee.co.th\/labs\/wp-json\/wp\/v2\/tags?post=3363"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}