{"id":307,"date":"2015-04-08T14:50:57","date_gmt":"2015-04-08T05:50:57","guid":{"rendered":"http:\/\/naochang.me\/?p=307"},"modified":"2021-10-17T18:51:13","modified_gmt":"2021-10-17T09:51:13","slug":"unityevent%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6","status":"publish","type":"post","link":"https:\/\/stacstar.jp\/blog\/?p=307","title":{"rendered":"UnityEvent\u306b\u3064\u3044\u3066"},"content":{"rendered":"<p><a href=\"\/blog\/wp-content\/entries\/150408_UnityEvent\/unity_event.html\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" src=\"\/blog\/wp-content\/entries\/150408_UnityEvent\/image.png\"><\/a><\/p>\n<p>Unity4.6\u304b\u3089uGUI\u304c\u8ffd\u52a0\u3055\u308c\u305f\u969b\u306b\u3001<a href=\"http:\/\/docs.unity3d.com\/ja\/current\/ScriptReference\/Events.UnityEvent.html\" target=\"_blank\" rel=\"noopener noreferrer\">UnityEvent<\/a>\u3068\u3044\u3046\u30a4\u30d9\u30f3\u30c8\u30b7\u30b9\u30c6\u30e0\u3082\u8ffd\u52a0\u3055\u308c\u307e\u3057\u305f\u3002<br \/>\nuGUI\u3068\u540c\u6642\u306b\u8ffd\u52a0\u3055\u308c\u305f\u306e\u3067\u3001uGUI\u3067\u6271\u3046\u30a4\u30d9\u30f3\u30c8\u30b7\u30b9\u30c6\u30e0\u7cfb\u304b\u3068\u601d\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u304c\u3042\u3089\u3086\u308b\u5834\u9762\u3067\u5229\u7528\u304c\u3067\u304d\u307e\u3059\u3002<br \/>\n<a href=\"\/blog\/?p=105\" target=\"_blank\" rel=\"noopener noreferrer\">\u4ee5\u524d\u3001\u30a4\u30d9\u30f3\u30c8\u306b\u3064\u3044\u3066\u3069\u306e\u3088\u3046\u306a\u3084\u308a\u65b9\u304c\u3044\u3044\u304b\u8a66\u3057\u3066\u307f\u305f\u3093\u3067\u3059\u304c<\/a>\u3001\u305d\u306e\u969b\u306b\u4f5c\u3063\u305f\u3082\u306e\u306bUnityEvent\u3067\u306e\u3084\u308a\u65b9\u3092\u8ffd\u52a0\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p><a href=\"\/blog\/wp-content\/entries\/150408_UnityEvent\/unity_event.zip\">&gt;&gt;\u30b5\u30f3\u30d7\u30eb\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9<\/a><\/p>\n<p><!--more--><\/p>\n<p>\u8ffd\u52a0\u3057\u305f\u4e3b\u306a\u30bd\u30fc\u30b9\u3092\u629c\u304d\u51fa\u3059\u3068<\/p>\n<p>\/\/ UIManager\u5074<\/p>\n<pre class=\"brush: unitycsharp; title: ; notranslate\" title=\"\">\r\nusing UnityEngine.Events;\r\n\r\n\/**\r\n * UnityEvent\u306e\u7528\u610f\u3002\r\n *\/\r\npublic UnityEvent rotateEvent;\r\n\r\n\/\/ UnityEvent\u306e\u767a\u884c\r\nthis.rotateEvent.Invoke();\r\n<\/pre>\n<p>\/\/ \u30a4\u30d9\u30f3\u30c8\u3092\u53d7\u3051\u308bUnityEventTest\u5074<\/p>\n<pre class=\"brush: unitycsharp; title: ; notranslate\" title=\"\">\r\nusing UnityEngine;\r\nusing System.Collections;\r\n\r\n\/\/\/ &lt;summary&gt;\r\n\/\/\/ UnityEvent\u3092\u53d7\u3051\u53d6\u308b\u30c6\u30b9\u30c8\u3002\r\n\/\/\/ &lt;\/summary&gt;\r\npublic class UnityEventTest : MonoBehaviour {\r\n\t\/\/\/ &lt;summary&gt;\r\n\t\/\/\/ UIManager.\r\n\t\/\/\/ &lt;\/summary&gt;\r\n\tUIManager uiManager;\r\n\r\n\t\/\/\/ &lt;summary&gt;\r\n\t\/\/\/ Awake.\r\n\t\/\/\/ &lt;\/summary&gt;\r\n\tpublic void Awake() {\r\n\t\tthis.uiManager = GameObject.Find(&quot;UIManager&quot;).GetComponent&lt;UIManager&gt;();\r\n\t}\r\n\r\n\t\/\/\/ &lt;summary&gt;\r\n\t\/\/\/ \u30ad\u30e5\u30fc\u30d6\u3092\u56de\u8ee2\u3055\u305b\u308b\u3002\r\n\t\/\/\/ &lt;\/summary&gt;\r\n\tpublic void RotateCube() {\r\n\t\tthis.transform.Rotate(0, 10, 0);\r\n\r\n\t\tif (this.transform.rotation.eulerAngles.y &gt;= 60) {\r\n\t\t\tthis.uiManager.rotateEvent.RemoveListener(this.RotateCube);\r\n\t\t\tDestroy(this.gameObject);\r\n\t\t}\r\n\t}\r\n}\r\n<\/pre>\n<p>\u3053\u308c\u3060\u3051\u3067\u5b9f\u88c5\u3067\u304d\u307e\u3057\u305f\u3002<br \/>\n\u4eca\u56de\u30a4\u30d9\u30f3\u30c8\u306e\u8ffd\u52a0\u306f\u30a4\u30f3\u30b9\u30da\u30af\u30bf\u30fc\u4e0a\u3067\u3001\u30a4\u30d9\u30f3\u30c8\u306e\u524a\u9664\u306f\u30bd\u30fc\u30b9\u4e0a(RemoveListener)\u3067\u884c\u3044\u307e\u3057\u305f\u3002<br \/>\nevent EventHandler\u3088\u308a\u3082\u5bb9\u6613\u306b\u6271\u3048\u307e\u3059\u3002<br \/>\n\u30a4\u30d9\u30f3\u30c8\u3092\u767b\u9332\u3057\u3066\u3044\u308bGameObject\u304c\u7834\u68c4\u3055\u308c\u308b\u3068UnityEvent\u5074\u304b\u3089\u52dd\u624b\u306b\u7834\u68c4\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3001\u3072\u3087\u3063\u3068\u3057\u305f\u3089RemoveListener\u3057\u306a\u304f\u3066\u3082\u81ea\u52d5\u3067\u884c\u308f\u308c\u308b\u306e\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002\uff08\u672a\u78ba\u8a8d\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Unity4.6\u304b\u3089uGUI\u304c\u8ffd\u52a0\u3055\u308c\u305f\u969b\u306b\u3001UnityEvent\u3068\u3044\u3046\u30a4\u30d9\u30f3\u30c8\u30b7\u30b9\u30c6\u30e0\u3082\u8ffd\u52a0\u3055\u308c\u307e\u3057\u305f\u3002 uGUI\u3068\u540c\u6642\u306b\u8ffd\u52a0\u3055\u308c\u305f\u306e\u3067\u3001uGUI\u3067\u6271\u3046\u30a4\u30d9\u30f3\u30c8\u30b7\u30b9\u30c6\u30e0\u7cfb\u304b\u3068\u601d\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u304c\u3042\u3089\u3086\u308b\u5834\u9762\u3067\u5229\u7528\u304c\u3067\u304d\u307e [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-307","post","type-post","status-publish","format-standard","hentry","category-unity"],"_links":{"self":[{"href":"https:\/\/stacstar.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/307","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/stacstar.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/stacstar.jp\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/stacstar.jp\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/stacstar.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=307"}],"version-history":[{"count":7,"href":"https:\/\/stacstar.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/307\/revisions"}],"predecessor-version":[{"id":1960,"href":"https:\/\/stacstar.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/307\/revisions\/1960"}],"wp:attachment":[{"href":"https:\/\/stacstar.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=307"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/stacstar.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=307"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/stacstar.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=307"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}