{"action":"created","comment":{"url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/pulls/comments/80963539","pull_request_review_id":1979525,"id":80963539,"diff_hunk":"@@ -0,0 +1,84 @@\n+﻿// Copyright (c) Microsoft Corporation. All rights reserved.\n+// Licensed under the MIT License. See LICENSE in the project root for license information.\n+\n+using UnityEngine;\n+\n+namespace HoloToolkit.Unity\n+{\n+    /// <summary>\n+    /// Use this class for easy access to OnTap, OnGazeEnder, and OnGazeExit events.\n+    /// Be sure to override each of these methods with your own implimentation.\n+    /// Examples of code usage in each method below in comments.\n+    /// </summary>\n+    [RequireComponent(typeof(Collider))]\n+    public class Interactable : MonoBehaviour\n+    {\n+        protected virtual void OnEnable()\n+        {\n+            GestureManager.Instance.OnTap += OnTap;\n+            GazeManager.Instance.OnGazeExit += OnGazeExit;\n+            GazeManager.Instance.OnGazeEnter += OnGazeEnter;\n+        }\n+\n+        protected virtual void OnDisable()\n+        {\n+            GestureManager.Instance.OnTap -= OnTap;\n+            GazeManager.Instance.OnGazeExit -= OnGazeExit;\n+            GazeManager.Instance.OnGazeEnter -= OnGazeEnter;\n+        }\n+\n+        /// <summary>\n+        /// Called when a user has tapped any GameObject.\n+        /// </summary>\n+        /// <param name=\"tappedGameObject\">GameObject user has tapped.</param>\n+        protected virtual void OnTap(GameObject tappedGameObject)\n+        {\n+            // Do something if ANY GameObject has been tapped.","path":"Assets/HoloToolkit/Input/Scripts/Interactable.cs","position":36,"original_position":36,"commit_id":"185971ef821eaeb8608fa5a4113da7fcf1cd75ed","original_commit_id":"185971ef821eaeb8608fa5a4113da7fcf1cd75ed","user":{"login":"HodgsonSDAS","id":13334553,"avatar_url":"https://avatars.githubusercontent.com/u/13334553?v=3","gravatar_id":"","url":"https://api.github.com/users/HodgsonSDAS","html_url":"https://github.com/HodgsonSDAS","followers_url":"https://api.github.com/users/HodgsonSDAS/followers","following_url":"https://api.github.com/users/HodgsonSDAS/following{/other_user}","gists_url":"https://api.github.com/users/HodgsonSDAS/gists{/gist_id}","starred_url":"https://api.github.com/users/HodgsonSDAS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HodgsonSDAS/subscriptions","organizations_url":"https://api.github.com/users/HodgsonSDAS/orgs","repos_url":"https://api.github.com/users/HodgsonSDAS/repos","events_url":"https://api.github.com/users/HodgsonSDAS/events{/privacy}","received_events_url":"https://api.github.com/users/HodgsonSDAS/received_events","type":"User","site_admin":false},"body":"I agree. These were mainly to show examples of how people may use this in the future.","created_at":"2016-09-28T16:47:27Z","updated_at":"2016-09-28T16:47:27Z","html_url":"https://github.com/Microsoft/HoloToolkit-Unity/pull/227#discussion_r80963539","pull_request_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/pulls/227","_links":{"self":{"href":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/pulls/comments/80963539"},"html":{"href":"https://github.com/Microsoft/HoloToolkit-Unity/pull/227#discussion_r80963539"},"pull_request":{"href":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/pulls/227"}}},"pull_request":{"url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/pulls/227","id":86228726,"html_url":"https://github.com/Microsoft/HoloToolkit-Unity/pull/227","diff_url":"https://github.com/Microsoft/HoloToolkit-Unity/pull/227.diff","patch_url":"https://github.com/Microsoft/HoloToolkit-Unity/pull/227.patch","issue_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/issues/227","number":227,"state":"open","locked":false,"title":"Replace GameObject.SendMessage(\"Method\") with event delegates","user":{"login":"HodgsonSDAS","id":13334553,"avatar_url":"https://avatars.githubusercontent.com/u/13334553?v=3","gravatar_id":"","url":"https://api.github.com/users/HodgsonSDAS","html_url":"https://github.com/HodgsonSDAS","followers_url":"https://api.github.com/users/HodgsonSDAS/followers","following_url":"https://api.github.com/users/HodgsonSDAS/following{/other_user}","gists_url":"https://api.github.com/users/HodgsonSDAS/gists{/gist_id}","starred_url":"https://api.github.com/users/HodgsonSDAS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HodgsonSDAS/subscriptions","organizations_url":"https://api.github.com/users/HodgsonSDAS/orgs","repos_url":"https://api.github.com/users/HodgsonSDAS/repos","events_url":"https://api.github.com/users/HodgsonSDAS/events{/privacy}","received_events_url":"https://api.github.com/users/HodgsonSDAS/received_events","type":"User","site_admin":false},"body":"Pull request for issue https://github.com/Microsoft/HoloToolkit-Unity/issues/224\r\n\r\nMany [experienced Unity developers](http://jacksondunstan.com/articles/3335) would probably tell you not use [GameObject.SendMessage(\"String\");](https://docs.unity3d.com/ScriptReference/GameObject.SendMessage.html) because [it's slow](http://answers.unity3d.com/questions/327888/is-sendmessage-slow-.html) (under the hood it uses reflection), hard to debug, and it lacks direct symbol references in the editor which makes it prone to spelling errors _because_ it's a string and not a symbol. This can also make it difficult to find everywhere the method referenced can be called and could potentially increase the amount of spaghetti code.  It may be worth while to see this updated to utilize a [delegate/Event call instead](https://unity3d.com/learn/tutorials/topics/scripting/events?playlist=17117).\r\n\r\n## TL;DR\r\nThis will make the code easier to follow in the editor, easier to debug, and will increase performance.\r\n\r\n## [Some arguments for using a delegate vs SendMessage](http://answers.unity3d.com/questions/185980/sendbroadcast-message-vs-delegates-and-events.html):\r\n\r\n> SendMessage and delegates are used for similar purposes, but they work entirely differently. Delegates/Events behave exactly like they do in any other .Net program. SendMessage() is called much like Unity calls other messages like Update(). Unity reflects over all the code on the game object to see if it can invoke any messages.\r\n> \r\n> As far as performance. Delegates are several times faster than SendMessage. In the order of performance:\r\n> \r\n`(Least) Direct Method Call ==> Delegate/Event ==> Update() ==> SendMessage (Most Expensive)`\r\n> As far as usage, SendMessage is like a very broad direct method call. The general paradigm is that one script specifically wants to send a message to a specific object. We're just not sure how many times is can respond or if it can respond at all. We know the intended receiver, we just don't know if it can receive the message.\r\n> \r\n> With events, I usually follow the idea that the event owner doesn't know who or how many objects might respond. We are simply telling the world that something happened without too much knowledge of who will use this information.\r\n\r\nThis means if you try to trigger or respond to an event with the wrong type, you'll get a compiler error... where as if you do the wrong thing with SendMessage you'll get a runtime error that's much harder to track down.  Another major benefit of using Delegate/Event is type checking. A delegate specifies specific types that must be passed as parameters, while SendMessage just accepts an object.","created_at":"2016-09-21T19:45:43Z","updated_at":"2016-09-28T16:47:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2c3c902a1eae45ae77cb2d3e1a0210dc4b2e50a1","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/pulls/227/commits","review_comments_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/pulls/227/comments","review_comment_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/issues/227/comments","statuses_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/statuses/185971ef821eaeb8608fa5a4113da7fcf1cd75ed","head":{"label":"HodgsonSDAS:master","ref":"master","sha":"185971ef821eaeb8608fa5a4113da7fcf1cd75ed","user":{"login":"HodgsonSDAS","id":13334553,"avatar_url":"https://avatars.githubusercontent.com/u/13334553?v=3","gravatar_id":"","url":"https://api.github.com/users/HodgsonSDAS","html_url":"https://github.com/HodgsonSDAS","followers_url":"https://api.github.com/users/HodgsonSDAS/followers","following_url":"https://api.github.com/users/HodgsonSDAS/following{/other_user}","gists_url":"https://api.github.com/users/HodgsonSDAS/gists{/gist_id}","starred_url":"https://api.github.com/users/HodgsonSDAS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HodgsonSDAS/subscriptions","organizations_url":"https://api.github.com/users/HodgsonSDAS/orgs","repos_url":"https://api.github.com/users/HodgsonSDAS/repos","events_url":"https://api.github.com/users/HodgsonSDAS/events{/privacy}","received_events_url":"https://api.github.com/users/HodgsonSDAS/received_events","type":"User","site_admin":false},"repo":{"id":68851517,"name":"HoloToolkit-Unity","full_name":"HodgsonSDAS/HoloToolkit-Unity","owner":{"login":"HodgsonSDAS","id":13334553,"avatar_url":"https://avatars.githubusercontent.com/u/13334553?v=3","gravatar_id":"","url":"https://api.github.com/users/HodgsonSDAS","html_url":"https://github.com/HodgsonSDAS","followers_url":"https://api.github.com/users/HodgsonSDAS/followers","following_url":"https://api.github.com/users/HodgsonSDAS/following{/other_user}","gists_url":"https://api.github.com/users/HodgsonSDAS/gists{/gist_id}","starred_url":"https://api.github.com/users/HodgsonSDAS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HodgsonSDAS/subscriptions","organizations_url":"https://api.github.com/users/HodgsonSDAS/orgs","repos_url":"https://api.github.com/users/HodgsonSDAS/repos","events_url":"https://api.github.com/users/HodgsonSDAS/events{/privacy}","received_events_url":"https://api.github.com/users/HodgsonSDAS/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/HodgsonSDAS/HoloToolkit-Unity","description":"This is effectively part of the existing HoloToolkit, but is the repo that will contain all Unity specific components.","fork":true,"url":"https://api.github.com/repos/HodgsonSDAS/HoloToolkit-Unity","forks_url":"https://api.github.com/repos/HodgsonSDAS/HoloToolkit-Unity/forks","keys_url":"https://api.github.com/repos/HodgsonSDAS/HoloToolkit-Unity/keys{/key_id}","collaborators_url":"https://api.github.com/repos/HodgsonSDAS/HoloToolkit-Unity/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/HodgsonSDAS/HoloToolkit-Unity/teams","hooks_url":"https://api.github.com/repos/HodgsonSDAS/HoloToolkit-Unity/hooks","issue_events_url":"https://api.github.com/repos/HodgsonSDAS/HoloToolkit-Unity/issues/events{/number}","events_url":"https://api.github.com/repos/HodgsonSDAS/HoloToolkit-Unity/events","assignees_url":"https://api.github.com/repos/HodgsonSDAS/HoloToolkit-Unity/assignees{/user}","branches_url":"https://api.github.com/repos/HodgsonSDAS/HoloToolkit-Unity/branches{/branch}","tags_url":"https://api.github.com/repos/HodgsonSDAS/HoloToolkit-Unity/tags","blobs_url":"https://api.github.com/repos/HodgsonSDAS/HoloToolkit-Unity/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/HodgsonSDAS/HoloToolkit-Unity/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/HodgsonSDAS/HoloToolkit-Unity/git/refs{/sha}","trees_url":"https://api.github.com/repos/HodgsonSDAS/HoloToolkit-Unity/git/trees{/sha}","statuses_url":"https://api.github.com/repos/HodgsonSDAS/HoloToolkit-Unity/statuses/{sha}","languages_url":"https://api.github.com/repos/HodgsonSDAS/HoloToolkit-Unity/languages","stargazers_url":"https://api.github.com/repos/HodgsonSDAS/HoloToolkit-Unity/stargazers","contributors_url":"https://api.github.com/repos/HodgsonSDAS/HoloToolkit-Unity/contributors","subscribers_url":"https://api.github.com/repos/HodgsonSDAS/HoloToolkit-Unity/subscribers","subscription_url":"https://api.github.com/repos/HodgsonSDAS/HoloToolkit-Unity/subscription","commits_url":"https://api.github.com/repos/HodgsonSDAS/HoloToolkit-Unity/commits{/sha}","git_commits_url":"https://api.github.com/repos/HodgsonSDAS/HoloToolkit-Unity/git/commits{/sha}","comments_url":"https://api.github.com/repos/HodgsonSDAS/HoloToolkit-Unity/comments{/number}","issue_comment_url":"https://api.github.com/repos/HodgsonSDAS/HoloToolkit-Unity/issues/comments{/number}","contents_url":"https://api.github.com/repos/HodgsonSDAS/HoloToolkit-Unity/contents/{+path}","compare_url":"https://api.github.com/repos/HodgsonSDAS/HoloToolkit-Unity/compare/{base}...{head}","merges_url":"https://api.github.com/repos/HodgsonSDAS/HoloToolkit-Unity/merges","archive_url":"https://api.github.com/repos/HodgsonSDAS/HoloToolkit-Unity/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/HodgsonSDAS/HoloToolkit-Unity/downloads","issues_url":"https://api.github.com/repos/HodgsonSDAS/HoloToolkit-Unity/issues{/number}","pulls_url":"https://api.github.com/repos/HodgsonSDAS/HoloToolkit-Unity/pulls{/number}","milestones_url":"https://api.github.com/repos/HodgsonSDAS/HoloToolkit-Unity/milestones{/number}","notifications_url":"https://api.github.com/repos/HodgsonSDAS/HoloToolkit-Unity/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/HodgsonSDAS/HoloToolkit-Unity/labels{/name}","releases_url":"https://api.github.com/repos/HodgsonSDAS/HoloToolkit-Unity/releases{/id}","deployments_url":"https://api.github.com/repos/HodgsonSDAS/HoloToolkit-Unity/deployments","created_at":"2016-09-21T19:40:15Z","updated_at":"2016-09-21T19:40:18Z","pushed_at":"2016-09-28T14:28:21Z","git_url":"git://github.com/HodgsonSDAS/HoloToolkit-Unity.git","ssh_url":"git@github.com:HodgsonSDAS/HoloToolkit-Unity.git","clone_url":"https://github.com/HodgsonSDAS/HoloToolkit-Unity.git","svn_url":"https://github.com/HodgsonSDAS/HoloToolkit-Unity","homepage":"","size":43384,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"MSFT_Holotoolkit-master"}},"base":{"label":"Microsoft:master","ref":"master","sha":"9fdde95877d731e622da57a355db0f3c41f4996b","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":50605426,"name":"HoloToolkit-Unity","full_name":"Microsoft/HoloToolkit-Unity","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft/HoloToolkit-Unity","description":"This is effectively part of the existing HoloToolkit, but is the repo that will contain all Unity specific components.","fork":false,"url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity","forks_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/forks","keys_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/teams","hooks_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/events","assignees_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/tags","blobs_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/languages","stargazers_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/subscription","commits_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/merges","archive_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/downloads","issues_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/releases{/id}","deployments_url":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/deployments","created_at":"2016-01-28T18:54:58Z","updated_at":"2016-09-28T14:31:54Z","pushed_at":"2016-09-28T14:28:21Z","git_url":"git://github.com/Microsoft/HoloToolkit-Unity.git","ssh_url":"git@github.com:Microsoft/HoloToolkit-Unity.git","clone_url":"https://github.com/Microsoft/HoloToolkit-Unity.git","svn_url":"https://github.com/Microsoft/HoloToolkit-Unity","homepage":"","size":43615,"stargazers_count":293,"watchers_count":293,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":172,"mirror_url":null,"open_issues_count":38,"forks":172,"open_issues":38,"watchers":293,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/pulls/227"},"html":{"href":"https://github.com/Microsoft/HoloToolkit-Unity/pull/227"},"issue":{"href":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/issues/227"},"comments":{"href":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/issues/227/comments"},"review_comments":{"href":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/pulls/227/comments"},"review_comment":{"href":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/pulls/227/commits"},"statuses":{"href":"https://api.github.com/repos/Microsoft/HoloToolkit-Unity/statuses/185971ef821eaeb8608fa5a4113da7fcf1cd75ed"}}}}
{"actor":{"display_login":"HodgsonSDAS"}}