{"id":1704,"date":"2015-12-11T10:46:27","date_gmt":"2015-12-11T02:46:27","guid":{"rendered":"http:\/\/blog.1vr.cn\/?p=1704"},"modified":"2015-12-11T10:46:27","modified_gmt":"2015-12-11T02:46:27","slug":"unity%e5%bc%80%e5%8f%91vr%e7%9c%bc%e9%95%9c%e4%b8%ad%e6%96%87%e5%85%a5%e9%97%a8%e6%95%99%e7%a8%8b3","status":"publish","type":"post","link":"https:\/\/1vr.cn\/?p=1704","title":{"rendered":"UNITY\u5f00\u53d1VR\u773c\u955c\u4e2d\u6587\u5165\u95e8\u6559\u7a0b(3)"},"content":{"rendered":"<h2>VR\u4e2d\u7684\u4ea4\u4e92<\/h2>\n<p>&nbsp;<\/p>\n<h3>\u6982\u8ff0<\/h3>\n<p>&nbsp;<\/p>\n<p>\u5728VR\u4e2d\u6211\u4eec\u7ecf\u5e38\u9700\u8981\u6fc0\u6d3b\u7528\u6237\u6b63\u5728\u770b\u7684\u5bf9\u8c61,\u6bd4\u5982VRSamples\u4e2d,\u6211\u4eec\u5185\u5efa\u4e86\u4e00\u4e2a\u7b80\u5355\u7684\u53ef\u6269\u5c55\u7684,\u8f7b\u91cf\u7ea7\u7528\u6237\u4ea4\u4e92\u7cfb\u7edf\u6846\u67b6.\u5b83\u5305\u62ec\u4e86\u4e09\u4e2a\u4e3b\u8981\u811a\u672c::VREyeRaycaster, VRInput, \u548c VRInteractiveItem,\u4e0b\u9762\u5bf9\u5b83\u4eec\u8fdb\u884c\u7b80\u8981\u7684\u8bf4\u660e.<\/p>\n<h3>VREyeRaycaster<\/h3>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1651\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/1_vreyeraycaster.png\" sizes=\"auto, (max-width: 599px) 100vw, 599px\" srcset=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/1_vreyeraycaster-300x89.png 300x, http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/1_vreyeraycaster.png 599x\" alt=\"1_vreyeraycaster\" width=\"599\" height=\"178\" \/><\/p>\n<p>\u8fd9\u4e2a\u811a\u672c\u9700\u8981\u653e\u7f6e\u5728Main Camera.\u5728\u6bcf\u4e2aUpdate()\u4e2d\u811a\u672c\u4f1a\u7528\u00a0<a href=\"http:\/\/docs.unity3d.com\/ScriptReference\/Physics.Raycast.html\">Physics.Raycast<\/a>\u53bb\u5c04\u7ebf\u7ed9\u4efb\u4f55\u770b\u5230\u7684\u78b0\u649e\u5668.\u5f53\u7136\u4e5f\u53ef\u4ee5\u901a\u8fc7\u5c42(<a href=\"http:\/\/docs.unity3d.com\/Manual\/Layers.html\">docs.unity3d.com\/Manual\/Layers.html<\/a>)\u7684\u8bbe\u7f6e\u505a\u6392\u9664.\u4e5f\u53ef\u4ee5\u5c06\u6240\u6709\u9700\u8981\u4e92\u52a8\u7684\u5bf9\u8c61\u653e\u5230\u4e00\u4e2a\u5355\u72ec\u7684\u5c42\u4e2d\u6765\u4f18\u5316\u6027\u80fd.<\/p>\n<p>\u5982\u679c\u5c04\u7ebf\u6295\u5c04\u5230\u4e86\u4e00\u4e2a\u78b0\u649e\u5668,\u8fd9\u4e2a\u811a\u672c\u5c06\u53bb\u627e\u8fd9\u4e2a\u6e38\u620f\u5bf9\u8c61\u4e0a\u7684<i>VRInteractiveItem<\/i>\u7ec4\u4ef6.<\/p>\n<pre>VRInteractiveItem interactible = hit.collider.GetComponent&lt;VRInteractiveItem&gt;();\u00a0 \u00a0 \/\/\u8bd5\u56fe\u83b7\u5f97\u88ab\u5c04\u5bf9\u8c61\u4e0a\u7684VRInteractiveItem\u7ec4\u4ef6<\/pre>\n<p>\u56e0\u6b64\u6211\u4eec\u53ef\u4ee5\u5224\u65ad\u7528\u6237\u662f\u5426\u5728\u770b\u4e00\u4e2a\u7269\u4f53\u6216\u8005\u4e0d\u518d\u770b\u8fd9\u4e2a\u7269\u4f53,\u901a\u8fc7\u8fd9\u4e2a\u72b6\u6001\u7684\u83b7\u53d6\u518d\u53bb\u505a\u76f8\u5e94\u7684\u52a8\u4f5c.<\/p>\n<h3>VRInput<\/h3>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1645\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/2_vrinput.png\" sizes=\"auto, (max-width: 568px) 100vw, 568px\" srcset=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/2_vrinput-300x39.png 300x, http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/2_vrinput.png 568x\" alt=\"2_vrinput\" width=\"568\" height=\"73\" \/><\/p>\n<p>VRInput \u662f\u4e00\u4e2a\u7b80\u5355\u7684\u5224\u65ad\u5728GearVR\u8bbe\u5907\u4e2d\u53d1\u751f\u7684\u5355\u51fb,\u53cc\u51fb,\u6ed1\u52a8\u7684\u7c7b\u6216DK2\u5728PC\u505a\u540c\u6837\u7684\u8f93\u5165.\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u4eceVRInput\u4e2d\u83b7\u53d6\u8f93\u5165\u4e8b\u4ef6:<\/p>\n<pre>public event Action&lt;SwipeDirection&gt; OnSwipe;\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/\u5728\u6bcf\u4e00\u5e27\u4e2d\u6ed1\u52a8\u6216\u6ca1\u6709\u6ed1\u52a8\u4e8b\u4ef6\u65f6\u8c03\u7528\r\npublic event Action OnClick;\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/ \u5f53Fire1\u952e\u88ab\u89e6\u53d1\u4e14\u4e0d\u662f\u53cc\u51fb\u65f6\u8c03\u7528.\r\npublic event Action OnDown; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/ \u5728Fire1\u88ab\u6309\u4e0b\u65f6\u8c03\u7528\r\npublic event Action OnUp; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/ \u5728Fire1\u88ab\u677e\u5f00\u65f6\u8c03\u7528.\r\npublic event Action OnDoubleClick;\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/ \u5f53\u68c0\u6d4b\u5230\u53cc\u51fb\u4e8b\u4ef6\u65f6\u88ab\u8c03\u7528.\r\npublic event Action OnCancel; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/ \u5f53Cancel\u88ab\u89e6\u53d1\u65f6\u8c03\u7528.<\/pre>\n<p>\u66f4\u591a\u8f93\u5165\u4e8b\u4ef6\u7684\u4fe1\u606f\u8bf7\u67e5\u9605(<a href=\"http:\/\/unity3d.com\/ru\/learn\/tutorials\/modules\/intermediate\/scripting\/events\">unity3d.com\/ru\/learn\/tutorials\/modules\/intermediate\/scripting\/events<\/a>).<\/p>\n<h3>VRInteractiveItem<\/h3>\n<p>&nbsp;<\/p>\n<p>\u8fd9\u4e2a\u7ec4\u4ef6\u53ef\u4ee5\u6dfb\u52a0\u5230VR\u4e2d\u4efb\u4f55\u5e0c\u671b\u7528\u6237\u4ea4\u4e92\u7684\u6e38\u620f\u7269\u4f53\u4e0a.\u5b83\u9700\u8981\u7269\u4f53\u4e0a\u9644\u52a0\u4e00\u4e2a\u78b0\u649e\u5668\u7ec4\u4ef6.<\/p>\n<p>\u5728\u7269\u4f53\u4e0a\u6211\u4eec\u53ef\u4ee5\u83b7\u5f97\u516d\u79cd\u4e8b\u4ef6:<\/p>\n<pre>public event Action OnOver; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/\u5f53\u76ee\u5149\u79fb\u5230\u8fd9\u4e2a\u7269\u4f53\u4e0a\u65f6\u89e6\u53d1.\r\npublic event Action OnOut;\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/\u5f53\u76ee\u5149\u5df2\u5230\u8fd9\u4e2a\u7269\u4f53\u4e0a\u65f6\u89e6\u53d1.\r\npublic event Action OnClick;\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/\u5f53\u8fd9\u4e2a\u7269\u4f53\u88ab\u51dd\u89c6\u5e76\u4e14\u6709\u70b9\u51fb\u4e8b\u4ef6\u65f6\u89e6\u53d1.\r\npublic event Action OnDoubleClick;\u00a0 \u00a0 \u00a0 \/\/\u5f53\u8fd9\u4e2a\u7269\u4f53\u88ab\u51dd\u89c6\u5e76\u4e14\u6709\u53cc\u51fb\u4e8b\u4ef6\u65f6\u88ab\u89e6\u53d1.\r\npublic event Action OnUp; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/\u5f53\u8fd9\u4e2a\u7269\u4f53\u88ab\u51dd\u89c6\u5e76\u4e14\u677e\u5f00Fire1\u952e\u65f6\u88ab\u89e6\u53d1.\r\npublic event Action OnDown; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/ \u5f53\u8fd9\u4e2a\u7269\u4f53\u88ab\u51dd\u89c6\u5e76\u4e14\u6309\u4e0bFire1\u952e\u65f6\u88ab\u89e6\u53d1.<\/pre>\n<p>\u4ee5\u53ca\u4e00\u4e2a\u5e03\u5c14\u503c\u6765\u83b7\u5f97\u5f53\u524d\u7269\u4f53\u662f\u5426\u88ab\u51dd\u89c6:<\/p>\n<pre>public bool IsOver\r\n{\r\nget{ return m_IsOver;} \/\/\u5f53\u524d\u8fd9\u4e2a\u7269\u4f53\u88ab\u51dd\u89c6\u5417?\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u521b\u5efa\u81ea\u5df1\u7684\u811a\u672c\u6765\u5bf9\u8fd9\u4e9b\u4e8b\u4ef6\u505a\u51fa\u76f8\u5e94\u7684\u53cd\u5e94.\u4e0b\u9762\u8fd9\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\u6f14\u793a\u8fd9\u4e9b\u4e8b\u4ef6\u7684\u4f7f\u7528:<\/p>\n<pre>using UnityEngine;\r\nusing VRStandardAssets.Utils;\r\nnamespace VRStandardAssets.Examples\r\n{\r\n\/\/ \u8fd9\u662f\u4e00\u4e2a\u4e0e\u7269\u4f53\u4ea4\u4e92\u7684\u7b80\u5355\u4f8b\u5b50\r\n\/\/ \u88ab\u7528\u6765\u5904\u7406\u7269\u4f53\u54cd\u5e94\u8f93\u5165\u4e8b\u4ef6\r\npublic class ExampleInteractiveItem : MonoBehaviour\r\n{\r\n[SerializeField] private Material m_NormalMaterial;\r\n[SerializeField] private Material m_OverMaterial;\r\n[SerializeField] private Material m_ClickedMaterial;\r\n[SerializeField] private Material m_DoubleClickedMaterial;\r\n[SerializeField] private VRInteractiveItem m_InteractiveItem;\r\n[SerializeField] private Renderer m_Renderer;\r\nprivate void Awake ()\r\n{\r\nm_Renderer.material = m_NormalMaterial;\r\n}\r\nprivate void OnEnable()\r\n{\r\nm_InteractiveItem.OnOver += HandleOver;\r\nm_InteractiveItem.OnOut += HandleOut;\r\nm_InteractiveItem.OnClick += HandleClick;\r\nm_InteractiveItem.OnDoubleClick += HandleDoubleClick;\r\n}\r\nprivate void OnDisable()\r\n{\r\nm_InteractiveItem.OnOver -= HandleOver;\r\nm_InteractiveItem.OnOut -= HandleOut;\r\nm_InteractiveItem.OnClick -= HandleClick;\r\nm_InteractiveItem.OnDoubleClick -= HandleDoubleClick;\r\n}\r\n\/\/\u5904\u7406\u5f53\u524d\u7269\u4f53\r\nprivate void HandleOver()\r\n{\r\nDebug.Log(\"Show over state\");\r\nm_Renderer.material = m_OverMaterial;\r\n}\r\n\/\/\u5904\u7406\u975e\u5f53\u524d\u7269\u4f53\r\nprivate void HandleOut()\r\n{\r\nDebug.Log(\"Show out state\");\r\nm_Renderer.material = m_NormalMaterial;\r\n}\r\n\/\/\u5904\u7406\u5355\u51fb\u4e8b\u4ef6\r\nprivate void HandleClick()\r\n{\r\nDebug.Log(\"Show click state\");\r\nm_Renderer.material = m_ClickedMaterial;\r\n}\r\n\/\/\u5904\u7406\u53cc\u51fb\u4e8b\u4ef6\r\nprivate void HandleDoubleClick()\r\n{\r\nDebug.Log(\"Show double click\");\r\nm_Renderer.material = m_DoubleClickedMaterial;\r\n}\r\n}\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<p>\u5173\u4e8e\u8fd9\u6bb5\u811a\u672c\u7684\u5b8c\u6574\u793a\u4f8b\u8bf7\u67e5\u770bVR\u793a\u4f8b\u7684<i>VRSampleScenes\/Scenes\/Examples\/InteractiveItem<\/i>\u573a\u666f<\/p>\n<h3>\u73af\u72b6\u9009\u62e9\u6846(SelectionRadial) \u548c \u6ed1\u5757\u9009\u62e9\u6761(SelectionSlider)<\/h3>\n<p>&nbsp;<\/p>\n<p>\u6211\u4eec\u505a\u4e2a\u73af\u72b6\u9009\u62e9\u6846\u53ca\u6ed1\u5757\u9009\u62e9\u6761,\u8ba9\u7528\u6237\u51dd\u89c6\u7269\u4f53\u5e76\u6309\u4f4fFire1\u952e\u5b9e\u73b0\u201d\u786e\u5b9a\u201d\u547d\u4ee4\u7684\u4ea4\u4e92:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1635\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/3_selectionradial.png\" sizes=\"auto, (max-width: 524px) 100vw, 524px\" srcset=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/3_selectionradial-300x262.png 300x, http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/3_selectionradial.png 524x\" alt=\"3_selectionradial\" width=\"524\" height=\"457\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1631\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/4_selectionslider.png\" sizes=\"auto, (max-width: 622px) 100vw, 622px\" srcset=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/4_selectionslider-300x140.png 300x, http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/4_selectionslider.png 622x\" alt=\"4_selectionslider\" width=\"622\" height=\"290\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>\u968f\u7740\u8f93\u5165\u7684\u6301\u7eed,\u9009\u62e9\u680f\u8fdb\u884c\u586b\u5145,\u5e76\u4ea7\u751f<i>OnSelectionComplete<\/i>\u00a0\u6216 \u88ab\u586b\u6ee1\u65f6<i>OnBarFilled<\/i>\u00a0\u4e8b\u4ef6,\u76f8\u5173\u4ee3\u7801\u53ef\u4ee5\u5728\u00a0<i>electionRadial.cs<\/i>\u00a0\u548c<i>SelectionSlider.cs<\/i>\u4e2d\u627e\u5230,\u6709\u5f88\u8be6\u5c3d\u7684\u6ce8\u91ca.\u4ece\u7528\u6237\u4f53\u9a8c\u4e0a\u6765\u8bb2\u8ba9\u7528\u6237\u77e5\u9053\u4ed6\u4eec\u5728\u505a\u4ec0\u4e48,\u80fd\u51c6\u786e\u7684\u786e\u5b9a\u6216\u53d6\u6d88\u4e0e\u865a\u62df\u4e16\u754c\u7684\u4ea4\u4e92.<\/p>\n<h2>VR\u793a\u4f8b\u4e2d\u7684\u4ea4\u4e92<\/h2>\n<p>&nbsp;<\/p>\n<p>\u73b0\u5728\u8ba9\u6211\u4eec\u6765\u770bVR\u793a\u4f8b\u4e2d\u5305\u542b\u7684\u4ea4\u4e92\u529f\u80fd,\u4e86\u89e3\u5b83\u4eec\u662f\u5982\u4f55\u5b9e\u73b0\u7684.<\/p>\n<h3>Menu\u573a\u666f\u7684\u4ea4\u4e92<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1652\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/5_menu.png\" sizes=\"auto, (max-width: 624px) 100vw, 624px\" srcset=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/5_menu-300x115.png 300x, http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/5_menu.png 624x\" alt=\"5_menu\" width=\"624\" height=\"240\" \/><\/p>\n<p>\u6bcf\u9879\u83dc\u5355\u90fd\u6709\u597d\u51e0\u4e2a\u7ec4\u4ef6,\u8fd9\u91cc\u6211\u4eec\u91cd\u70b9\u770b\u00a0<i>MenuButton<\/i>,\u00a0<i>VRInteractiveItem<\/i>, \u548c\u00a0<i>Mesh Collider<\/i>.<\/p>\n<p>&nbsp;<\/p>\n<p><i>MenuButton<\/i>\u7ec4\u4ef6\u7528\u6765\u83b7\u5f97\u5728<i>VRInteractiveItem\u00a0<\/i>\u7ec4\u4ef6\u4e0a\u7684<i>OnOver<\/i>\u00a0\u548c\u00a0<i>OnOut<\/i>\u4e8b\u4ef6.\u6240\u4ee5\u5f53\u89c6\u91ce\u5728\u83dc\u5355\u9879\u65f6,\u9009\u62e9\u6761\u5c06\u586b\u5145\u51fa\u73b0,\u76ee\u5149\u4e0d\u5728\u83dc\u5355\u9879\u65f6,\u9009\u62e9\u6761\u51cf\u5c0f\u586b\u5145.\u5f53\u9009\u62e9\u6761\u5b8c\u5168\u586b\u6ee1\u5e76\u6309\u4f4fFire1\u65f6\u5c06\u51fa\u73b0\u73af\u72b6\u9009\u62e9\u6846\u5f00\u59cb\u586b\u5145:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1655\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/6_selectionradial.png\" sizes=\"auto, (max-width: 524px) 100vw, 524px\" srcset=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/6_selectionradial-300x262.png 300x, http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/6_selectionradial.png 524x\" alt=\"6_selectionradial\" width=\"524\" height=\"457\" \/><\/p>\n<p>\u540c\u6837\u7684\u5728\u73af\u72b6\u9009\u62e9\u6761\u586b\u6ee1\u65f6\u4e5f\u6709<i>OnSelectionComplete<\/i>\u00a0\u4e8b\u4ef6,\u7136\u540e<i>HandleSelectionComplete<\/i>\u88ab\u8c03\u7528,\u63a5\u7740\u76f8\u673a\u955c\u5934\u6de1\u51fa\u540e\u8f7d\u5165\u9009\u62e9\u7684\u5173\u5361.<\/p>\n<pre>private void OnEnable ()\r\n{\r\nm_InteractiveItem.OnOver += HandleOver;\r\nm_InteractiveItem.OnOut += HandleOut;\r\nm_SelectionRadial.OnSelectionComplete += HandleSelectionComplete;\r\n}\r\nprivate void OnDisable ()\r\n{\r\nm_InteractiveItem.OnOver -= HandleOver;\r\nm_InteractiveItem.OnOut -= HandleOut;\r\nm_SelectionRadial.OnSelectionComplete -= HandleSelectionComplete;\r\n}\r\nprivate void HandleOver()\r\n{\r\n\/\/ \u5f53\u7528\u6237\u6b63\u5728\u51dd\u89c6\u573a\u666f\u83dc\u5355\u9879\u65f6,\u663e\u793a\u73af\u72b6\u9009\u62e9\u6761.\r\nm_SelectionRadial.Show();\r\nm_GazeOver = true;\r\n}\r\nprivate void HandleOut()\r\n{\r\n\/\/ \u5f53\u7528\u6237\u4e0d\u5728\u51dd\u89c6\u573a\u666f\u83dc\u5355\u9879\u65f6,\u9690\u85cf\u73af\u72b6\u9009\u62e9\u6761.\r\nm_SelectionRadial.Hide();\r\nm_GazeOver = false;\r\n}\r\nprivate void HandleSelectionComplete()\r\n{\r\n\/\/ \u5f53\u7528\u6237\u51dd\u89c6\u51dd\u89c6\u83dc\u5355\u9879\u5e76\u4e14\u73af\u72b6\u9009\u62e9\u6761\u586b\u5145\u6ee1\u65f6\u6fc0\u6d3b\u6309\u94ae.\r\nif(m_GazeOver)\r\nStartCoroutine (ActivateButton());\r\n}\r\nprivate IEnumerator ActivateButton()\r\n{\r\n\/\/ \u5982\u679c\u76f8\u673a\u5df2\u7ecf\u6de1\u51fa\u5219\u5ffd\u7565\r\nif (m_CameraFade.IsFading)\r\nyield break;\r\n\/\/ \u5728\u6709\u4efb\u4f55\u6309\u94ae\u9009\u62e9\u4e8b\u4ef6\u53d1\u751f\u65f6\u8c03\u53bb\u5b83\r\nif (OnButtonSelected != null)\r\nOnButtonSelected(this);\r\n\/\/ \u7b49\u5f85\u76f8\u673a\u7684\u6de1\u51fa\r\nyield return StartCoroutine(m_CameraFade.BeginFadeOut(true));\r\n\/\/ \u8f7d\u5165\u5173\u5361\r\nSceneManager.LoadScene(m_SceneToLoad, LoadSceneMode.Single);\r\n}<\/pre>\n<p>\u8ba9\u6211\u4eec\u770b\u770b\u73af\u72b6\u9009\u62e9\u6846\u7684\u793a\u4f8b,\u6ce8\u610f\u89c6\u91ce\u622a\u56fe\u4e2d\u5fc3\u7684\u7c89\u7ea2\u5706\u70b9.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1657\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/7_radial-off.png\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" srcset=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/7_radial-off-300x154.png 300x, http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/7_radial-off.png 700x\" alt=\"7_radial-off\" width=\"700\" height=\"359\" \/><\/p>\n<p>\u5f53\u7528\u6237\u51dd\u89c6\u83dc\u5355\u9879\u65f6\u53ef\u4ee5\u770b\u5230\u8fd8\u672a\u5f00\u59cb\u586b\u5145\u7684\u73af\u72b6\u9009\u62e9\u6846.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1632\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/8_radial-on.png\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" srcset=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/8_radial-on-300x167.png 300x, http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/8_radial-on.png 700x\" alt=\"8_radial-on\" width=\"700\" height=\"389\" \/><\/p>\n<p>\u5f53\u7528\u6237\u7ee7\u7eed\u51dd\u89c6\u8fd9\u4e2a\u83dc\u5355\u9879\u5e76\u4e14\u6309\u4e0bFire1\u952e,\u4f1a\u770b\u5230\u73af\u72b6\u9009\u62e9\u6846\u5f00\u59cb\u586b\u5145<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1636\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/9_radial-filling.png\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" srcset=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/9_radial-filling-300x159.png 300x, http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/9_radial-filling.png 700x\" alt=\"9_radial-filling\" width=\"700\" height=\"370\" \/><\/p>\n<p>\u6211\u4eec\u5efa\u8bae\u8ba9\u73af\u72b6\u9009\u62e9\u6846\u548c\u6ed1\u5757\u9009\u62e9\u6761\u7684\u65f6\u95f4\u4e00\u81f4,\u63d0\u5347\u7528\u6237\u4f53\u9a8c,\u4ee5\u5e2e\u52a9\u7528\u6237\u66f4\u5feb\u7684\u4f7f\u7528VR\u8fd9\u79cd\u65b0\u5a92\u4ecb.<\/p>\n<h3>Maze\u573a\u666f\u4e2d\u7684\u4ea4\u4e92<\/h3>\n<p>&nbsp;<\/p>\n<p>Maze\u6e38\u620f\u63d0\u4f9b\u4e86\u4e00\u4e2a\u684c\u6e38\u5f62\u5f0f\u4e92\u52a8\u7684\u4f8b\u5b50,\u901a\u8fc7\u5f15\u5bfc\u89d2\u8272\u5230\u51fa\u53e3\u518d\u901a\u8fc7\u5f00\u5173\u963b\u6b62\u70ae\u5854\u7684\u653b\u51fb(\u5267\u900f\u4e86!!).<\/p>\n<p>\u5f53\u9009\u62e9\u4e00\u4e2a\u89d2\u8272,\u8fd9\u4e2a\u89d2\u8272\u4f1a\u51fa\u73b0\u4e00\u6761\u5373\u5c06\u884c\u8d70\u7684\u8def\u7ebf,\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u6ed1\u52a8\u89e6\u63a7\u677f,\u6309\u4e0b\u5149\u6807\u952e\u6216\u7528\u6e38\u620f\u624b\u67c4\u7684\u5de6\u6447\u6746\u6765\u65cb\u8f6c\u89c6\u56fe.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1630\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/10_maze-scene-overview.png\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" srcset=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/10_maze-scene-overview-300x180.png 300x, http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/10_maze-scene-overview.png 700x\" alt=\"10_maze-scene-overview\" width=\"700\" height=\"421\" \/><\/p>\n<p><i>MazeFloor<\/i>\u00a0\u7269\u4f53\u7528\u4e00\u4e2a<i>MeshCollider<\/i>\u00a0\u548c<i>VRInteractiveItem<\/i>\u00a0\u7ec4\u4ef6\u6765\u5b9e\u73b0\u4ea4\u4e92:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1653\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/11_mazefloor.png\" sizes=\"auto, (max-width: 487px) 100vw, 487px\" srcset=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/11_mazefloor-300x185.png 300x, http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/11_mazefloor.png 487x\" alt=\"11_mazefloor\" width=\"487\" height=\"301\" \/><\/p>\n<p>MazeCourse \u6e38\u620f\u7269\u4f53\u4f5c\u4e3a\u7236\u7269\u4f53,\u5305\u542b\u4e86 MazeFloor \u548c MazeWalls\u6e38\u620f\u5bf9\u8c61,\u7528\u4e8e\u6784\u6210\u8ff7\u5bab\u7684\u5e03\u5c40.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1634\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/12_mazecourse.png\" alt=\"12_mazecourse\" width=\"257\" height=\"120\" \/><\/p>\n<p>\u6709\u4e00\u4e2a<i>MazeTargetSetting\u00a0<\/i>\u811a\u672c\u5728MazeCourse\u4e0a\u5e76\u5f15\u7528\u4e86MazeFloor\u4e0a\u7684<i>VRInteractiveItem\u00a0<\/i>\u7ec4\u4ef6.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1650\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/13_mazetargetsetting.png\" sizes=\"auto, (max-width: 487px) 100vw, 487px\" srcset=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/13_mazetargetsetting-300x45.png 300x, http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/13_mazetargetsetting.png 487x\" alt=\"13_mazetargetsetting\" width=\"487\" height=\"73\" \/><\/p>\n<p><i>MazeTargetSetting<\/i>\u00a0\u83b7\u53d6\u5230<i>VRInteractiveItem<\/i>\u4e0a\u7684<i>OnDoubleClick<\/i>\u4e8b\u4ef6, \u7136\u540e\u5c06\u8c03\u7528<i>OnTargetSet<\/i>\u00a0\u4e8b\u4ef6,\u901a\u8fc7\u8f6c\u6362\u4f5c\u4e3aTransform\u7684\u53c2\u6570:<\/p>\n<pre>public event Action&lt;Transform&gt; OnTargetSet; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/ \u5f53\u76ee\u7684\u5730\u8bbe\u5b9a\u540e\u89e6\u53d1\r\nprivate void OnEnable()\r\n{\r\nm_InteractiveItem.OnDoubleClick += HandleDoubleClick;\r\n}\r\nprivate void OnDisable()\r\n{\r\nm_InteractiveItem.OnDoubleClick -= HandleDoubleClick;\r\n}\r\nprivate void HandleDoubleClick()\r\n{\r\n\/\/ \u4e00\u65e6\u76ee\u6807\u8bbe\u5b9a\u542f\u7528\u53ca\u83b7\u53d6\u4e86OnTargetSet\u4e8b\u4ef6\u5c31\u6267\u884c\u8fd9\u4e2a\u65b9\u6cd5.\r\nif (m_Active &amp;&amp; OnTargetSet != null)\r\nOnTargetSet (m_Reticle.ReticleTransform);\r\n}<\/pre>\n<p>\u65e0\u8bbaMazeCharacter\u6e38\u620f\u5bf9\u8c61\u4e0a\u7684Player\u7ec4\u4ef6\u8fd8\u662f\u5728MazeDestinationMarkerGUI\u6e38\u620f\u5bf9\u8c61\u4e0a\u7684<i>DestinationMarker<\/i>\u7ec4\u4ef6\u83b7\u53d6\u5230\u8fd9\u4e2a\u4e8b\u4ef6,\u90fd\u4f1a\u505a\u51fa\u76f8\u5e94\u7684\u53cd\u5e94.<\/p>\n<p>\u89d2\u8272\u7528\u5bfc\u822a\u7f51\u4e2a\u7cfb\u7edf\u53bb\u5728\u8ff7\u5bab\u4e2d\u5bfb\u8def.Player\u7ec4\u4ef6\u4e2dHandleSetTarget\u51fd\u6570\u88ab\u8bbe\u7f6e\u6210\u00a0<a href=\"http:\/\/docs.unity3d.com\/Manual\/nav-CreateNavMeshAgent.html\">Nav Mesh Agent<\/a>(docs.unity3d.com\/Manual\/nav-CreateNavMeshAgent.html)\u53bb\u54cd\u5e94\u53d8\u6362\u4f4d\u7f6e,\u5e76\u66f4\u65b0\u7ed8\u5236Agent\u7684\u8def\u7ebf,\u8ba9\u89d2\u8272\u8def\u5f84\u53ef\u89c6\u5316:<\/p>\n<pre>private void HandleSetTarget(Transform target)\r\n{\r\n\/\/ \u5982\u679c\u6e38\u620f\u6ca1\u6709\u7ed3\u675f\u5219\u8bbe\u5b9a\u89d2\u8272\u7684AI\u548c\u8def\u5f84\u7ebf\r\nif (m_IsGameOver)\r\nreturn;\r\nm_AiCharacter.SetTarget(target.position);\r\nm_AgentTrail.SetDestination();\r\n}<\/pre>\n<p><i>DestinationMarker<\/i>\u00a0\u79fb\u52a8\u6807\u8bc6\u7269\u5230\u51c6\u661f\u7684Transform\u4f4d\u7f6e.<\/p>\n<pre>private void HandleTargetSet(Transform target)\r\n{\r\n\/\/ \u5f53\u76ee\u6807\u88ab\u8bbe\u5b9a\u5c31\u663e\u793a\u6807\u8bc6\u7269\r\nShow();\r\n\/\/ \u628a\u51c6\u661f\u76ee\u6807\u4f4d\u7f6e\u8d4b\u4e88\u6807\u8bc6\u7269\u7684\u4f4d\u7f6e\r\ntransform.position = target.position;\r\n\/\/ \u64ad\u653e\u97f3\u6548.\r\nm_MarkerMoveAudio.Play();\r\n\/\/ \u64ad\u653e\u6807\u8bc6\u7269\u7684\u52a8\u753b\r\nm_Animator.Play(m_HashMazeNavMarkerAnimState, -1, 0.0f);\r\n}<\/pre>\n<p>\u53ef\u4ee5\u770b\u5230\u88ab\u6807\u8bc6\u7269\u76ee\u7684\u5730\u7684\u51c6\u661f\u53ca\u6240\u9009\u89d2\u8272\u7684\u884c\u52a8\u8f68\u8ff9.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1648\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/14_mazevideo02.gif\" alt=\"14_mazevideo02\" width=\"700\" height=\"350\" \/><\/p>\n<p>\u8ff7\u5bab\u4e2d\u7684\u89e6\u53d1\u5f00\u5173\u4e5f\u662fVR\u4e2d\u5e38\u7528\u7684\u4ea4\u4e92\u4f8b\u5b50.\u672c\u6587\u4f7f\u7528\u78b0\u649e\u5668\u4ee5\u53ca<i>VRInteractiveItem<\/i>\u548c<i>SelectionSlider<\/i>\u7c7b\u6765\u5b9e\u73b0.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1640\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/15_selectionslider-inspector.png\" sizes=\"auto, (max-width: 487px) 100vw, 487px\" srcset=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/15_selectionslider-inspector-300x274.png 300x, http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/15_selectionslider-inspector.png 487x\" alt=\"15_selectionslider-inspector\" width=\"487\" height=\"444\" \/><\/p>\n<p>\u5982\u4e0a\u56fe\u6240\u793a\u7684\u8981\u63a5\u53d7\u4ea4\u4e92\u5bf9\u8c61\u7684\u811a\u672c,<i>SelectionSlider\u00a0<\/i>\u811a\u672c\u76d1\u542c\u6765\u81ea<i>VRInteractiveItem<\/i>\u00a0\u548c\u00a0<i>VRInput<\/i>\u7684\u4e8b\u4ef6:<\/p>\n<pre>private void OnEnable ()\r\n{\r\nm_VR<a href=\"http:\/\/docs.unity3d.com\/Documentation\/ScriptReference\/Input.OnDown.html\">Input.OnDown<\/a> += HandleDown;\r\nm_VR<a href=\"http:\/\/docs.unity3d.com\/Documentation\/ScriptReference\/Input.OnUp.html\">Input.OnUp<\/a> += HandleUp;\r\nm_InteractiveItem.OnOver += HandleOver;\r\nm_InteractiveItem.OnOut += HandleOut;\r\n}<\/pre>\n<h3>Flyer\u573a\u666f\u4e2d\u7684\u4ea4\u4e92<\/h3>\n<p>Flyer\u573a\u666f\u662f\u4e00\u4e2a\u6709\u65f6\u95f4\u9650\u5236\u6e38\u620f,\u73a9\u5bb6\u5f15\u5bfc\u592a\u7a7a\u4e2d\u7684\u98de\u8239\u8eb2\u907f\u5c0f\u884c\u661f,\u7528Fire1\u952e\u5c04\u51fb\u5c0f\u884c\u661f,\u7a7f\u8d8a\u79ef\u5206\u5708\u83b7\u5f97\u79ef\u5206\u7b49\u7b49.\u8fd9\u6e38\u620f\u6709\u70b9\u50cf\u98de\u884c\u4ff1\u4e50\u90e8\u548c\u661f\u9645\u706b\u72d0.<\/p>\n<p>\u5728\u4e92\u52a8\u65b9\u9762,Flyer\u662f\u975e\u5e38\u7b80\u5355\u7684;\u4f7f\u7528<i>FlyerLaserController<\/i>\u83b7\u53d6VRInput\u4e2d\u7684OnDown\u4e8b\u4ef6\u53d1\u5c04\u6fc0\u5149\u5c04\u51fb:<\/p>\n<pre>private void OnEnable()\r\n{\r\nm_VR<a href=\"http:\/\/docs.unity3d.com\/Documentation\/ScriptReference\/Input.OnDown.html\">Input.OnDown<\/a> += HandleDown;\r\n}\r\nprivate void HandleDown()\r\n{\r\n\/\/\u5982\u679c\u6e38\u620f\u6ca1\u6709\u8fd0\u884c\u7ec8\u6b62\u6267\u884c\r\nif (!m_GameController.IsGameRunning)\r\nreturn;\r\n\/\/ \u4ece\u4efb\u610f\u4f4d\u7f6e\u53d1\u5c04\u6fc0\u5149\u675f\r\nSpawnLaser(m_LaserSpawnPosLeft);\r\nSpawnLaser(m_LaserSpawnPosRight);\r\n}<\/pre>\n<h3>Shooter180 \u548c Shooter360\u573a\u666f\u4e2d\u7684\u4ea4\u4e92(180\u5ea6\u7b2c\u4e00\u4eba\u79f0\u5c04\u51fb\u548c360\u5ea6\u5b88\u5821\u5f0f\u5c04\u51fb)<\/h3>\n<p>&nbsp;<\/p>\n<p>VR\u793a\u4f8b\u4e2d\u6709\u4e24\u4e2a\u76ee\u6807\u5c04\u51fb\u6e38\u620f,\u6709\u70b9\u8fd1\u4f3cX\u6218\u8b66\u7684\u573a\u666f\u753b\u9762,\u4e00\u4e2a\u662f180\u5ea6\u7684\u6cbf\u7740\u96a7\u9053\u884c\u8d70\u7684\u7b2c\u4e00\u89c6\u89d2\u5c04\u51fb\u6e38\u620f,\u53e6\u4e00\u4e2a\u662f\u539f\u5730360\u5ea6\u5b88\u5821\u5f0f\u7684\u5c04\u51fb\u6e38\u620f.<\/p>\n<p>\u5c04\u51fb\u6e38\u620f\u4e2d\u6bcf\u4e2a\u751f\u6210\u7684\u9776\u5b50\u90fd\u6709\u4e2a\u78b0\u649e\u5668,<i>VRInteractiveItem<\/i>\u00a0\u548c\u00a0<i>ShootingTarget.<\/i><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1638\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/16_shootingtargetobject.png\" sizes=\"auto, (max-width: 529px) 100vw, 529px\" srcset=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/16_shootingtargetobject-300x259.png 300x, http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/16_shootingtargetobject.png 529x\" alt=\"16_shootingtargetobject\" width=\"529\" height=\"456\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1646\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/17_shootingtarget.png\" sizes=\"auto, (max-width: 486px) 100vw, 486px\" srcset=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/17_shootingtarget-300x181.png 300x, http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/17_shootingtarget.png 486x\" alt=\"17_shootingtarget\" width=\"486\" height=\"294\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><i>ShootingTarget<\/i>\u81ea\u5df1\u83b7\u53d6<i>VRInteractiveItem<\/i>\u4e0a\u7684OnDown\u4e8b\u4ef6\u6765\u5224\u65ad\u76ee\u6807\u662f\u5426\u88ab\u51fb\u4e2d.\u8fd9\u79cd\u65b9\u6cd5\u9002\u5408\u7528\u4e0e\u70b9\u5c04,\u5982\u679c\u662f\u8fde\u53d1\u5c04\u51fb,\u6211\u4eec\u9700\u8981\u7528\u5176\u5b83\u65b9\u6848.<\/p>\n<p>\u6211\u4eec\u5bf9\u6e38\u620f\u91cc\u7684\u57fa\u672c\u4ea4\u4e92\u505a\u4e86\u6982\u8ff0\u4ee5\u53ca\u5b83\u4eec\u5728VR\u793a\u4f8b\u4e2d\u5982\u4f55\u7528\u7684.\u73b0\u5728\u6211\u4eec\u6765\u8ba8\u8bba\u5982\u4f55\u7528\u51dd\u89c6\u4f5c\u4e3a\u51c6\u661f.<\/p>\n<h2>\u51dd\u89c6<\/h2>\n<p>&nbsp;<\/p>\n<p>\u5728VR\u4e2d\u76d1\u6d4b\u7528\u6237\u89c6\u7ebf\u662f\u975e\u5e38\u91cd\u8981\u7684,\u65e0\u8bba\u662f\u5141\u8bb8\u7528\u6237\u4e0e\u5bf9\u8c61\u8fdb\u884c\u89e6\u53d1\u52a8\u753b\u7684\u4ea4\u4e92\u8fd8\u662f\u5411\u76ee\u6807\u5c04\u51fb.\u8bf7\u6ce8\u610f\u201d\u51dd\u89c6(GAZE)\u201d\u8fd9\u4e2a\u672f\u8bed,\u540e\u9762\u6211\u4eec\u4f1a\u7ecf\u5e38\u63d0\u5230.<\/p>\n<p>\u5927\u591a\u6570\u7684\u5934\u6234\u663e\u793a\u8bbe\u5907\u8fd8\u4e0d\u652f\u6301\u773c\u7403\u8ddf\u8e2a,\u6240\u4ee5\u6211\u4eec\u53ea\u80fd\u7528\u5934\u90e8\u7684\u671d\u5411\u6765\u4f30\u8ba1\u7528\u6237\u7684\u76ee\u5149\u671d\u5411.\u5982\u524d\u9762\u6982\u8ff0\u4e2d\u8bf4\u7684,\u6211\u4eec\u53ea\u9700\u5728\u76f8\u673a\u4e2d\u5fc3\u53d1\u5c04\u6761\u5c04\u7ebf\u7528\u5c04\u7ebf\u68c0\u6d4b\u76ee\u5149\u51dd\u89c6\u4ec0\u4e48\u5bf9\u8c61\u5c31\u53ef\u4ee5\u4e86.\u5f53\u7136,\u8fd9\u610f\u5473\u7740\u4efb\u4f55\u88ab\u68c0\u6d4b\u7684\u7269\u4f53\u90fd\u5fc5\u987b\u6709\u4e2a\u78b0\u649e\u5668\u7ec4\u4ef6.<\/p>\n<h3>\u51c6\u661f<\/h3>\n<p>&nbsp;<\/p>\n<p>\u4e00\u4e2a\u51c6\u661f\u7528\u6765\u663e\u793a\u7528\u6237\u89c6\u91ce\u4e2d\u5fc3,\u51c6\u661f\u7684\u6837\u5f0f\u53ef\u4ee5\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u70b9\u6216\u8005\u4e00\u4e2a\u5341\u5b57\u7ebf,\u8fd9\u53d6\u51b3\u4e8e\u4f60\u9879\u76ee\u7684\u98ce\u683c.<\/p>\n<p>\u4f20\u7edf\u6e38\u620f\u4e2d\u5f80\u5f80\u4f1a\u4f7f\u7528\u5341\u5b57\u7ebf\u4f5c\u4e3a\u51c6\u661f,\u5728VR\u4e2d\u505a\u51c6\u661f\u5b9a\u4f4d\u662f\u6709\u70b9\u590d\u6742\u7684:\u7528\u6237\u4f1a\u5c06\u773c\u775b\u7684\u7126\u70b9\u653e\u5728\u63a5\u8fd1\u4e8e\u76f8\u673a\u7684\u7269\u4f53\u4e0a,\u90a3\u4e48\u7528\u6237\u4f1a\u770b\u5230\u4e24\u4e2a\u51c6\u661f,\u6211\u4eec\u53ef\u4ee5\u628a\u624b\u6307\u653e\u5728\u773c\u524d\u6a21\u62df\u805a\u7126\u6548\u679c,\u624b\u6307\u79bb\u773c\u775b\u8d8a\u8fd1,\u80cc\u666f\u8d8a\u6a21\u7cca,\u53cd\u4e4b\u4ea6\u7136,\u8fd9\u5c31\u662f\u6240\u8c13\u7684\u81ea\u613f\u590d\u89c6(<a href=\"https:\/\/en.wikipedia.org\/wiki\/Diplopia#Voluntary\">voluntary Diplopia<\/a>(<a href=\"https:\/\/en.wikipedia.org\/wiki\/Diplopia#Voluntary\">https:\/\/en.wikipedia.org\/wiki\/Diplopia#Voluntary<\/a>)).<\/p>\n<p>\u4e3a\u4e86\u907f\u514d\u73a9\u5bb6\u770b\u573a\u666f\u65f6\u7531\u4e8e\u7126\u70b9\u4e0d\u540c\u51fa\u73b0\u4e24\u4e2a\u51c6\u661f,\u6211\u4eec\u9700\u8981\u5c06\u51c6\u661f\u653e\u5728\u73a9\u5bb6\u770b\u7684\u5bf9\u8c61\u7684\u8868\u9762\u4e0a.<\/p>\n<p>\u5982\u679c\u5355\u5355\u53bb\u79fb\u52a8\u51c6\u661f\u7684\u4f4d\u7f6e,\u5f53\u8ddd\u79bb\u8fdc\u65f6,\u51c6\u661f\u4f1a\u53d8\u5f97\u5f88\u5c0f,\u4e3a\u4e86\u4fdd\u8bc1\u51c6\u661f\u5927\u5c0f\u4e0d\u53d8,\u6211\u4eec\u9700\u8981\u6839\u636e\u5b83\u8ddd\u79bb\u76f8\u673a\u7684\u8ddd\u79bb\u53bb\u505a\u7f29\u653e.<\/p>\n<p>\u4e3a\u4e86\u8bf4\u660e\u8fd9\u4e2a\u7f29\u653e,\u53ef\u4ee5\u67e5\u770bExamples\/Reticle\u573a\u666f,\u5b83\u5305\u542b\u4e86\u4e0d\u540c\u8ddd\u79bb\u548c\u51c6\u661f\u7f29\u653e\u7684\u793a\u4f8b.<\/p>\n<p>\u51c6\u661f\u4f4d\u4e8e\u76f8\u673a\u6240\u89c2\u5bdf\u5230\u8f83\u8fd1\u7684\u4e00\u4e2a\u7269\u4f53\u4e0a:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1637\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/18_reticle-close.png\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" srcset=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/18_reticle-close-300x181.png 300x, http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/18_reticle-close.png 700x\" alt=\"18_reticle-close\" width=\"700\" height=\"423\" \/><\/p>\n<p>\u51c6\u661f\u5728\u4e00\u4e2a\u8f83\u8fdc\u7684\u7269\u4f53\u4e0a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1639\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/19_reticle-far.png\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" srcset=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/19_reticle-far-300x183.png 300x, http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/19_reticle-far.png 700x\" alt=\"19_reticle-far\" width=\"700\" height=\"426\" \/><\/p>\n<p>\u51c6\u661f\u4f4d\u4e8e\u66f4\u8fdc\u8ddd\u79bb\u7684\u4f4d\u7f6e:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1643\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/20_reticle-distance.png\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" srcset=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/20_reticle-distance-300x183.png 300x, http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/20_reticle-distance.png 700x\" alt=\"20_reticle-distance\" width=\"700\" height=\"426\" \/><\/p>\n<p>\u7531\u4e8e\u5b9a\u4f4d\u548c\u7f29\u653e\u51c6\u661f,\u6240\u4ee5\u7528\u6237\u4f1a\u89c9\u5f97\u51c6\u661f\u65e0\u8bba\u8ddd\u79bb\u591a\u8fdc\u90fd\u662f\u76f8\u540c\u7684\u5927\u5c0f,\u5f53\u51c6\u661f\u6ca1\u6709\u5904\u4e8e\u573a\u666f\u7684\u67d0\u4e2a\u5bf9\u8c61\u4e0a\u65f6,\u6211\u4eec\u53ea\u9700\u5c06\u51c6\u661f\u653e\u5728\u9884\u8ba2\u7684\u4e00\u4e2a\u8ddd\u79bb,\u8fd9\u4e2a\u8ddd\u79bb\u53d6\u51b3\u4e8e\u573a\u666f\u5927\u5c0f,\u6bd4\u5982\u4e00\u4e2a\u5ba4\u5916\u73af\u5883,\u6211\u4eec\u53ef\u4ee5\u628a\u51c6\u661f\u653e\u7f6e\u5728\u76f8\u673a\u8fdc\u4e00\u4e9b,\u800c\u5728\u5ba4\u5185\u573a\u666f,\u53ef\u80fd\u8ba9\u51c6\u661f\u8ddd\u79bb\u76f8\u673a\u66f4\u8fd1\u4e00\u4e9b.<\/p>\n<h3>\u5728\u6e38\u620f\u5bf9\u8c61\u4e0a\u7ed8\u5236\u51c6\u661f<\/h3>\n<p>&nbsp;<\/p>\n<p>\u5982\u679c\u5728\u7269\u4f53\u76f8\u540c\u4f4d\u7f6e\u7ed8\u5236\u51c6\u661f,\u90a3\u4e48\u51c6\u661f\u53ef\u80fd\u4f1a\u4e0e\u6e38\u620f\u5bf9\u8c61\u53d1\u751f\u7a7f\u63d2\u95ee\u9898:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1647\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/21_unity-reticle-clipped.png\" sizes=\"auto, (max-width: 473px) 100vw, 473px\" srcset=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/21_unity-reticle-clipped-300x296.png 300x, http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/21_unity-reticle-clipped.png 473x\" alt=\"21_unity-reticle-clipped\" width=\"473\" height=\"466\" \/><\/p>\n<p>\u8981\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898,\u6211\u4eec\u8981\u786e\u4fdd\u51c6\u661f\u6e32\u67d3\u4e8e\u573a\u666f\u4e2d\u6240\u6709\u7269\u4f53\u4e4b\u4e0a,\u8fd9\u91cc\u6211\u4eec\u7528\u5230\u57fa\u4e8eUnity\u5185\u7f6e\u7740\u8272\u5668\u201dUI\/Unlit\/Text\u201d\u6539\u5199\u540d\u4e3aUIOverlay.shader\u7740\u8272\u5668.\u4e3a\u6750\u8d28\u9009\u62e9\u7740\u8272\u5668\u65f6\u4f1a\u5728\u201dUI\/Overlay\u201d\u4e0b\u770b\u5230\u5b83.<\/p>\n<p>\u672c\u573a\u666f\u4e2d\u6709\u4e24\u4e2aUI\u63a7\u4ef6\u548c\u6587\u672c,\u5c06\u628a\u5b83\u753b\u5728\u573a\u666f\u4e2d\u5176\u5b83\u7269\u4f53\u4e4b\u4e0a:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1649\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/22_unity-reticle-noclipped.png\" sizes=\"auto, (max-width: 473px) 100vw, 473px\" srcset=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/22_unity-reticle-noclipped-300x296.png 300x, http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/22_unity-reticle-noclipped.png 473x\" alt=\"22_unity-reticle-noclipped\" width=\"473\" height=\"466\" \/><\/p>\n<p>\u5bf9\u9f50\u51c6\u661f\u5230\u573a\u666f\u4e2d\u7684\u7269\u4f53<\/p>\n<p>\u6700\u540e,\u6211\u4eec\u60f3\u5b9e\u73b0\u51c6\u661f\u7684\u65cb\u8f6c\u5339\u914d\u5230\u88ab\u9644\u52a0\u7684\u5bf9\u8c61\u6cd5\u7ebf,\u6211\u4eec\u53ef\u4ee5\u7528\u00a0<a href=\"http:\/\/docs.unity3d.com\/ScriptReference\/RaycastHit-normal.html\">RaycastHit.normal<\/a>(<a href=\"http:\/\/docs.unity3d.com\/ScriptReference\/RaycastHit-normal.html\">docs.unity3d.com\/ScriptReference\/RaycastHit-normal.html<\/a>),\u770b\u4e0b\u9762\u7684\u4ee3\u7801:<\/p>\n<pre>public void SetPosition (RaycastHit hit)\r\n{\r\nm_ReticleTransform.position = hit.point;\r\nm_ReticleTransform.localScale = m_OriginalScale * hit.distance;\r\n\/\/ \u5982\u679c\u7269\u4f53\u8868\u9762\u7684\u6cd5\u7ebf\u53ef\u4ee5\u88ab\u51c6\u661f\u4f7f\u7528\r\nif (m_UseNormal)\r\n\/\/ ... \u8bbe\u5b9a\u5b83\u7684\u6b63\u5411\u5411\u91cf\u65cb\u8f6c,\u4f7f\u5176\u6cbf\u7740\u6cd5\u7ebf\u65b9\u5411\r\nm_ReticleTransform.rotation = Quaternion.FromToRotation (<a href=\"http:\/\/docs.unity3d.com\/Documentation\/ScriptReference\/Vector3-forward.html\">Vector3.forward<\/a>, hit.normal);\r\nelse\r\n\/\/ \u7136\u540e\u5982\u679c\u6ca1\u6709\u6b63\u786e\u7684\u6cd5\u5411\u65b9\u5411\u53ef\u7528\u7684\u8bdd\u5c31\u8ba9\u5b83\u4fdd\u6301\u672c\u6765\u7684\u671d\u5411.\r\nm_ReticleTransform.localRotation = m_OriginalRotation;\r\n}<\/pre>\n<p>\u6211\u4eec\u53ef\u4ee5\u5728\u8ff7\u5bab\u573a\u666f\u4e2d\u770b\u5230\u51c6\u661f\u53e0\u52a0\u5230\u4e86\u5899\u4f53\u8868\u9762<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1654\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/23_unity-reticle-wall.png\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" srcset=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/23_unity-reticle-wall-300x192.png 300x, http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/23_unity-reticle-wall.png 700x\" alt=\"23_unity-reticle-wall\" width=\"700\" height=\"447\" \/><\/p>\n<p>\u8fd9\u91cc\u80fd\u770b\u5230\u51c6\u661f\u53e0\u52a0\u5230\u4e86\u5730\u677f\u4e0a:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1633\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/24_unity-reticle-floor.png\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" srcset=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/24_unity-reticle-floor-300x192.png 300x, http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/24_unity-reticle-floor.png 700x\" alt=\"24_unity-reticle-floor\" width=\"700\" height=\"447\" \/><\/p>\n<p>\u6211\u4eec\u540c\u6837\u63d0\u4f9b\u4e86\u5b8c\u6574\u7684\u793a\u4f8b\u811a\u672c\u6765\u8bf4\u660e\u901a\u8fc7<i>VREyeRaycaster<\/i>\u5b9a\u4f4d\u51c6\u661f\u5230\u51dd\u89c6\u5230\u7684\u7269\u4f53\u8868\u9762.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1656\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/25_reticle-inspector.png\" sizes=\"auto, (max-width: 469px) 100vw, 469px\" srcset=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/25_reticle-inspector-300x81.png 300x, http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/25_reticle-inspector.png 469x\" alt=\"25_reticle-inspector\" width=\"469\" height=\"126\" \/><\/p>\n<p>\u4ee5\u4e0a\u6240\u6709\u5185\u5bb9\u5747\u53ef\u5728<i>VRSampleScenes\/Scenes\/Examples\/<\/i>\u627e\u5230<\/p>\n<h2>VR\u4e2d\u5934\u90e8\u7684\u65cb\u8f6c\u548c\u4f4d\u7f6e<\/h2>\n<p>&nbsp;<\/p>\n<p>\u901a\u8fc7\u65cb\u8f6c\u5934\u90e8,\u5934\u6234\u5f0f\u663e\u793a\u8bbe\u5907\u53ef\u4ee5\u770b\u5468\u56f4\u7684\u73af\u5883,\u6709\u65f6\u5019\u6211\u4eec\u9700\u8981\u8bbf\u95ee\u8fd9\u4e2a\u89c6\u89d2\u503c.\u6211\u4eec\u5c31\u9700\u8981\u7528\u5230\u00a0<a href=\"http:\/\/docs.unity3d.com\/ScriptReference\/VR.InputTracking.html\">VR.InputTracking<\/a>(<a href=\"http:\/\/docs.unity3d.com\/ScriptReference\/VR.InputTracking.html\">docs.unity3d.com\/ScriptReference\/VR.InputTracking.html<\/a>)\u7c7b,\u5e76\u6307\u5b9a\u9700\u8981\u5f97\u5230\u54ea\u4e9bVRNode(<a href=\"http:\/\/docs.unity3d.com\/ScriptReference\/VR.VRNode.html\">docs.unity3d.com\/ScriptReference\/VR.VRNode.html<\/a>)\u6570\u636e.\u6bd4\u5982\u6211\u4eec\u8981\u83b7\u5f97\u5934\u90e8\u7684\u65cb\u8f6c,\u5c31\u8981\u7528VRNode.Head,\u800c\u4e0d\u662f\u53d6\u773c\u775b\u7684\u8282\u70b9.<\/p>\n<p>\u5728\u793a\u4f8b\u9879\u76ee\u4e2d\u53ef\u4ee5\u627e\u5230\u4e00\u4e2a\u57fa\u4e8e\u5934\u90e8\u65cb\u8f6c\u4f5c\u4e3a\u83dc\u5355\u9009\u62e9\u7684\u4f8b\u5b50,\u53ef\u4ee5\u770b<i>VRSampleScenes\/Examples\/Rotatio<\/i>n\u573a\u666f\u53ca<i>ExampleRotation<\/i>\u811a\u672c:<\/p>\n<pre>\/\/ \u5b58\u50a8\u6e38\u620f\u5bf9\u8c61\u7684\u65cb\u8f6c\u6b27\u62c9\u89d2\r\nvar eulerRotation = transform.rotation.eulerAngles;\r\n\/\/\u6839\u636e\u7528\u6237\u5934\u90e8\u7684y\u8f74\u503c\u8bbe\u5b9a\u5bf9\u8c61\u7684\u65cb\u8f6c\r\neulerRotation.x = 0;\r\neulerRotation.z = 0;\r\neulerRotation.y = InputTracking.GetLocalRotation(VRNode.Head).eulerAngles.y;<\/pre>\n<p>\u8fd0\u884c\u540e\u6211\u4eec\u5c31\u53ef\u4ee5\u770b\u5230\u6e38\u620f\u5bf9\u8c61\u662f\u5982\u4f55\u65cb\u8f6c\u7684:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1641\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/26_rotation-left.png\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" srcset=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/26_rotation-left-300x182.png 300x, http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/26_rotation-left.png 700x\" alt=\"26_rotation-left\" width=\"700\" height=\"425\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1644\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/27_rotation-right.png\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" srcset=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/27_rotation-right-300x183.png 300x, http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/27_rotation-right.png 700x\" alt=\"27_rotation-right\" width=\"700\" height=\"426\" \/><\/p>\n<p>\u5728Flyer\u6e38\u620f,\u6211\u4eec\u7528\u5934\u90e8\u52a8\u4f5c\u6765\u63a7\u5236\u98de\u8239\u7684\u4f4d,\u7ebf\u770b<i>FlyerMovementController<\/i>\u8fd9\u4e2a\u811a\u672c:<\/p>\n<pre>Quaternion headRotation = InputTracking.GetLocalRotation (VRNode.Head);\r\nm_TargetMarker.position = m_Camera.position + (headRotation * <a href=\"http:\/\/docs.unity3d.com\/Documentation\/ScriptReference\/Vector3-forward.html\">Vector3.forward<\/a>) * m_DistanceFromCamera;<\/pre>\n<h2><\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1642\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2015\/12\/28_flyervideo01.gif\" alt=\"28_flyervideo01\" width=\"700\" height=\"350\" \/><\/p>\n<h2><\/h2>\n<h2>\u5728VR\u6e38\u620f\u4e2d\u7528\u89e6\u63a7\u677f\u548c\u952e\u76d8\u4ea4\u4e92<\/h2>\n<p>&nbsp;<\/p>\n<p>Gear VR\u7684\u8bbe\u5907\u4fa7\u9762\u6709\u4e00\u5757\u89e6\u63a7\u677f,\u5728Unity\u4e2d\u76f8\u5f53\u4e8e\u9f20\u6807,\u6211\u4eec\u53ef\u4ee5\u7528\u5982\u4e0b\u7684\u547d\u4ee4:<\/p>\n<p><a href=\"http:\/\/docs.unity3d.com\/ScriptReference\/Input-mousePosition.html\">Input.mousePosition<\/a>(<a href=\"http:\/\/docs.unity3d.com\/ScriptReference\/Input-mousePosition.html\">docs.unity3d.com\/ScriptReference\/Input-mousePosition.html<\/a>)<\/p>\n<p><a href=\"http:\/\/docs.unity3d.com\/ScriptReference\/Input.GetMouseButtonDown.html\">Input.GetMouseButtonDown<\/a>(<a href=\"http:\/\/docs.unity3d.com\/ScriptReference\/Input.GetMouseButtonDown.html\">docs.unity3d.com\/ScriptReference\/Input.GetMouseButtonDown.html<\/a>)<\/p>\n<p><a href=\"http:\/\/docs.unity3d.com\/ScriptReference\/Input.GetMouseButtonUp.html\">Input.GetMouseButtonUp<\/a>(<a href=\"http:\/\/docs.unity3d.com\/ScriptReference\/Input.GetMouseButtonUp.html\">docs.unity3d.com\/ScriptReference\/Input.GetMouseButtonUp.html<\/a>)<\/p>\n<p>\u5728GearVR\u6211\u4eec\u4e5f\u53ef\u4ee5\u83b7\u5f97\u6ed1\u52a8\u8f93\u5165.\u5728\u793a\u4f8b\u811a\u672c<i>VRInput<\/i>\u4e2d\u5199\u597d\u4e86\u5173\u4e8e\u6ed1\u52a8,\u5355\u673a,\u53cc\u51fb\u7684\u8f93\u5165\u83b7\u53d6.\u4e5f\u540c\u6837\u652f\u6301\u6309\u952e\u76d8\u4e0a\u7684\u5de6Ctrl\u952e(Unity\u9ed8\u8ba4\u8f93\u5165\u672f\u8bed\u53ebFire1)\u6216\u9f20\u6807\u5de6\u952e\u7684\u9f20\u6807\u6ed1\u52a8\u6216\u9f20\u6807\u5355\u51fb.<\/p>\n<p>\u800c\u5728Unity\u7f16\u8f91\u5668\u4e2d,\u6211\u4eec\u5982\u679c\u7528DK2\u8bbe\u5907\u8fd8\u6ca1\u6709\u5f88\u597d\u7684\u529e\u6cd5\u6765\u6d4b\u8bd5Unity\u5f00\u53d1\u5230GearVR\u7684\u9879\u76ee.\u4e0d\u8fc7\u6211\u4eec\u53ef\u4ee5\u7528\u9f20\u6807\u6a21\u62df\u89e6\u63a7\u677f,\u914d\u5408\u952e\u76d8\u6765\u5b9e\u73b0\u6d4b\u8bd5.<\/p>\n<p>\u5de6Ctrel(Fire1)\u4f5c\u4e3a\u5355\u51fb,\u6ed1\u52a8\u9f20\u6807\u6a21\u62df\u89e6\u63a7\u677f\u7684\u6ed1\u52a8\u65cb\u8f6c\u7269\u4f53.<\/p>\n<p>\u53ef\u4ee5\u67e5\u770b<i>VRSampleScenes\/Scenes\/Examples\/Touchpad<\/i>\u573a\u666f\u4e86\u89e3\u4e0a\u9762\u8bf4\u5230\u7684\u8f93\u5165\u64cd\u4f5c.<\/p>\n<p>\u4e0b\u9762\u662f<i>ExampleTouchpad<\/i>\u811a\u672c,\u5b83\u4f9d\u7167\u6ed1\u52a8\u7684\u65b9\u5411\u7ed9\u7269\u4f53\u4e0a\u7684Rigidbody<\/p>\n<p>\u4ee5AddTorque\u5b9e\u73b0\u65cb\u8f6c.<\/p>\n<pre>using UnityEngine;\r\nusing VRStandardAssets.Utils;\r\nnamespace VRStandardAssets.Examples\r\n{\r\n\/\/ \u5904\u7406\u6ed1\u52a8\u63a7\u5236\u7684\u7b80\u5355\u811a\u672c\u4f8b\u5b50\r\npublic class ExampleTouchpad : MonoBehaviour\r\n{\r\n[SerializeField] private float m_Torque = 10f;\r\n[SerializeField] private VRInput m_VRInput;\r\n[SerializeField] private Rigidbody m_Rigidbody;\r\nprivate void OnEnable()\r\n{\r\nm_VR<a href=\"http:\/\/docs.unity3d.com\/Documentation\/ScriptReference\/Input.OnSwipe.html\">Input.OnSwipe<\/a> += HandleSwipe;\r\n}\r\nprivate void OnDisable()\r\n{\r\nm_VR<a href=\"http:\/\/docs.unity3d.com\/Documentation\/ScriptReference\/Input.OnSwipe.html\">Input.OnSwipe<\/a> -= HandleSwipe;\r\n}\r\n\/\/\u7ed9Ridigbody\u65bd\u52a0AddTorque\u6765\u5904\u7406\u6ed1\u52a8\u4e8b\u4ef6\r\nprivate void HandleSwipe(VR<a href=\"http:\/\/docs.unity3d.com\/Documentation\/ScriptReference\/Input.SwipeDirection.html\">Input.SwipeDirection<\/a> swipeDirection)\r\n{\r\nswitch (swipeDirection)\r\n{\r\ncase VR<a href=\"http:\/\/docs.unity3d.com\/Documentation\/ScriptReference\/Input.SwipeDirection.html\">Input.SwipeDirection<\/a>.NONE:\r\nbreak;\r\ncase VR<a href=\"http:\/\/docs.unity3d.com\/Documentation\/ScriptReference\/Input.SwipeDirection.html\">Input.SwipeDirection<\/a>.UP:\r\nm_Rigidbody.AddTorque(<a href=\"http:\/\/docs.unity3d.com\/Documentation\/ScriptReference\/Vector3-right.html\">Vector3.right<\/a> * m_Torque);\r\nbreak;\r\ncase VR<a href=\"http:\/\/docs.unity3d.com\/Documentation\/ScriptReference\/Input.SwipeDirection.html\">Input.SwipeDirection<\/a>.DOWN:\r\nm_Rigidbody.AddTorque(-<a href=\"http:\/\/docs.unity3d.com\/Documentation\/ScriptReference\/Vector3-right.html\">Vector3.right<\/a> * m_Torque);\r\nbreak;\r\ncase VR<a href=\"http:\/\/docs.unity3d.com\/Documentation\/ScriptReference\/Input.SwipeDirection.html\">Input.SwipeDirection<\/a>.LEFT:\r\nm_Rigidbody.AddTorque(<a href=\"http:\/\/docs.unity3d.com\/Documentation\/ScriptReference\/Vector3-up.html\">Vector3.up<\/a> * m_Torque);\r\nbreak;\r\ncase VR<a href=\"http:\/\/docs.unity3d.com\/Documentation\/ScriptReference\/Input.SwipeDirection.html\">Input.SwipeDirection<\/a>.RIGHT:\r\nm_Rigidbody.AddTorque(-<a href=\"http:\/\/docs.unity3d.com\/Documentation\/ScriptReference\/Vector3-up.html\">Vector3.up<\/a> * m_Torque);\r\nbreak;\r\n}\r\n}\r\n}\r\n}<\/pre>\n<h3>VR\u793a\u4f8b\u4e2d\u7684VRInput\u793a\u4f8b<\/h3>\n<p>&nbsp;<\/p>\n<p>\u5982\u4e0a\u6240\u8ff0,\u6211\u4eec\u5728\u793a\u4f8b\u6e38\u620f\u4e2d\u4f7f\u7528VRInput\u5904\u7406\u89e6\u6478\u677f\u548c\u952e\u76d8\u7684\u8f93\u5165.<\/p>\n<p>\u5728\u8ff7\u5bab\u6e38\u620f\u4e2d,<i>CameraOrbit<\/i>\u76d1\u542c\u6ed1\u52a8\u4e8b\u4ef6\u6765\u54cd\u5e94\u89c6\u56fe\u7684\u65cb\u8f6c.<\/p>\n<pre>private void OnEnable ()\r\n{\r\nm_Vr<a href=\"http:\/\/docs.unity3d.com\/Documentation\/ScriptReference\/Input.OnSwipe.html\">Input.OnSwipe<\/a> += HandleSwipe;\r\n}\r\nprivate void HandleSwipe(VR<a href=\"http:\/\/docs.unity3d.com\/Documentation\/ScriptReference\/Input.SwipeDirection.html\">Input.SwipeDirection<\/a> swipeDirection)\r\n{\r\n\/\/ \u5982\u679c\u6e38\u620f\u6ca1\u6709\u5f00\u59cb\u6216\u8005\u6b63\u5728\u64ad\u653e\u76f8\u673a\u6de1\u51fa\u6548\u679c,\u4e0d\u5904\u7406\u6ed1\u52a8\u8f93\u5165.\r\nif (!m_MazeGameController.Playing)\r\nreturn;\r\nif (m_CameraFade.IsFading)\r\nreturn;\r\n\/\/\u5426\u5219\u6839\u636e\u6ed1\u52a8\u7684\u8fdb\u884c\u76f8\u5e94\u7684\u6b63\u8f6c\u6216\u8d1f\u8f6c.\r\nswitch (swipeDirection)\r\n{\r\ncase VR<a href=\"http:\/\/docs.unity3d.com\/Documentation\/ScriptReference\/Input.SwipeDirection.html\">Input.SwipeDirection<\/a>.LEFT:\r\nStartCoroutine(RotateCamera(m_RotationIncrement));\r\nbreak;\r\ncase VR<a href=\"http:\/\/docs.unity3d.com\/Documentation\/ScriptReference\/Input.SwipeDirection.html\">Input.SwipeDirection<\/a>.RIGHT:\r\nStartCoroutine(RotateCamera(-m_RotationIncrement));\r\nbreak;\r\n}\r\n}<\/pre>\n<h1><\/h1>\n<hr \/>\n<p><strong>\u539f\u6587:<a href=\"http:\/\/unity3d.com\/learn\/tutorials\/topics\/virtual-reality\">http:\/\/unity3d.com\/learn\/tutorials\/topics\/virtual-reality<\/a><\/strong><\/p>\n<p><strong>\u7531 \u56db\u89d2\u94b1 (XK) \u7ffb\u8bd1,\u8f6c\u8f7d\u8bf7\u6ce8\u660e\u6765\u81ea http:\/\/blog.1vr.cn<\/strong><\/p>\n<h1><b>\u00a0<\/b><\/h1>\n","protected":false},"excerpt":{"rendered":"<p>VR\u4e2d\u7684\u4ea4\u4e92 &nbsp; \u6982\u8ff0 &nbsp; \u5728VR\u4e2d\u6211\u4eec\u7ecf\u5e38\u9700\u8981\u6fc0\u6d3b\u7528\u6237\u6b63\u5728\u770b\u7684\u5bf9\u8c61,\u6bd4\u5982VRSample &hellip; <a href=\"https:\/\/1vr.cn\/?p=1704\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">UNITY\u5f00\u53d1VR\u773c\u955c\u4e2d\u6587\u5165\u95e8\u6559\u7a0b(3)<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-1704","post","type-post","status-publish","format-standard","hentry","category-5","without-featured-image"],"_links":{"self":[{"href":"https:\/\/1vr.cn\/index.php?rest_route=\/wp\/v2\/posts\/1704","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/1vr.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/1vr.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/1vr.cn\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/1vr.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1704"}],"version-history":[{"count":2,"href":"https:\/\/1vr.cn\/index.php?rest_route=\/wp\/v2\/posts\/1704\/revisions"}],"predecessor-version":[{"id":1821,"href":"https:\/\/1vr.cn\/index.php?rest_route=\/wp\/v2\/posts\/1704\/revisions\/1821"}],"wp:attachment":[{"href":"https:\/\/1vr.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1704"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/1vr.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1704"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/1vr.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1704"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}