{"id":568,"date":"2016-08-12T10:54:07","date_gmt":"2016-08-12T02:54:07","guid":{"rendered":"http:\/\/39.100.100.179\/?p=568"},"modified":"2016-10-11T09:28:24","modified_gmt":"2016-10-11T01:28:24","slug":"htc-vive%e6%89%8b%e6%9f%84%e4%ba%8b%e4%bb%b6","status":"publish","type":"post","link":"http:\/\/www.u3d8.com\/?p=568","title":{"rendered":"HTC VIVE\u624b\u67c4\u4e8b\u4ef6"},"content":{"rendered":"<p>\u6587\u7ae0\u8f6c\u81ea\uff1ahttp:\/\/www.cnblogs.com\/czaoth\/p\/5610883.html<\/p>\n<div class=\"article_title\"><strong>\u7814\u7a76\u4e86\u51e0\u5929htc vive\u7684\u63a5\u53e3\uff0c\u603b\u7b97\u662f\u628a\u57fa\u672c\u7684\u6309\u952e\u529f\u80fd\u7814\u7a76\u51fa\u6765\u4e86\uff0c\u8fd9\u91cc\u5206\u4eab\u4e00\u4e0b\uff0c\u4e00\u6765\u5f53\u505a\u7b14\u8bb0\uff0c\u4e8c\u6765\u4e5f\u5e0c\u671b\u5bf9\u5927\u5bb6\u6709\u6240\u5e2e\u52a9\u3002<\/strong><\/div>\n<div id=\"article_content\" class=\"article_content\">\n<p><strong>\u5982\u4f55\u5bfc\u5165Steam_VR\u90a3\u4e2a\u5305\u4ec0\u4e48\u7684\u6211\u5c31\u4e0d\u8bf4\u4e86\uff0c\u7f51\u4e0a\u6709\u51e0\u4e2a\u524d\u8f88\u5df2\u7ecf\u6559\u4e86\uff0c\u86ee\u725b\u8bba\u575b\u5565\u7684\u4e0a\u9762\u90fd\u6709\uff0c\u8fd9\u91cc\u53ea\u628a\u6bd4\u8f83\u8be6\u7ec6\u7684\u6309\u952e\u529f\u80fd\u5206\u4eab\u4e00\u4e0b\uff0c\u4e0d\u77e5\u5565\u9ad8\u7aef\u7684\u4e1c\u897f\uff0c\u4e5f\u7b97\u4e00\u6bb5\u65f6\u95f4\u52b3\u52a8\u6210\u679c\u5566\uff0c\u6240\u4ee5\u8f6c\u8f7d\u7684\u5e2e\u6211\u7559\u4e2a\u540d\u5199\u4e2a\u8f6c\uff0c\u8c22\u8c22\u5566\u3002<\/strong><\/p>\n<p><strong>\u4e2a\u4eba\u611f\u89c9\u624b\u67c4\u4e0a\u5f00\u59cb\u6bd4\u8f83\u96be\u641e\u660e\u767d\u7684\u5c31\u662f\u90a3\u4e2a\u5706\u76d8\u952e\uff0c\u8fd9\u4e2a\u952e\u662f\u4e00\u4e2a\u4ee5\u4e2d\u5fc3\u4e3a\uff080,0\uff09\u70b9\u7684\u76f4\u89d2\u5750\u6807\u7cfb\uff0c\u56db\u4e2a\u7aef\u957f\u5ea6\u90fd\u662f1\uff0c\u53ef\u63a5\u6536\u89e6\u6478\u548c\u6309\u538b\u4e24\u79cd\u4e8b\u4ef6\uff0c\u5927\u4f53\u5c31\u662f\u4e0b\u56fe\u8fd9\u4e2a\u610f\u601d\uff08\u624b\u7ed8\u6c34\u5e73\u7565\u6e23\uff0c\u89c1\u8c05\u89c1\u8c05\uff09\uff0c\u89e6\u6478touch\u6216\u6309\u538bpress\u4f1a\u901a\u8fc7<\/strong>GetAxis\u65b9\u6cd5\u8fd4\u56de\u4e00\u4e2a\u5750\u6807\u7cfb\u4e2d\u7684\u70b9\uff0c\u53ef\u4ee5\u5224\u65ad\u4f60\u6309\u5728\u54ea\u91cc\uff0c\u89e6\u53d1\u4e0d\u540c\u7684\u4e8b\u4ef6\uff0c\u53ef\u4ee5\u6839\u636e\u89d2\u5ea6\u6216\u5404\u79cd\u65b9\u6cd5\u6765\u5207\u5206\u6309\u952e\u4e3an\u4e2a\u6309\u94ae\uff08\u5c31\u50cf\u5207\u86cb\u7cd5\u4e00\u6837\uff09<\/p>\n<p><strong>\u8fd9\u91cc\u7528\u7684\u662fC#\u811a\u672c \uff0c\u76f4\u63a5\u4e0a\u4ee3\u7801\u4e86\uff0c\u6211\u4e2a\u4eba\u5199\u6ce8\u91ca\u6bd4\u8f83\u8bdd\u5520\uff0c\u9002\u5408\u65b0\u624b\u770b\uff1a<\/strong><\/p>\n<pre class=\"lang:c# decode:true \">using UnityEngine;  \r\nusing System.Collections;  \r\n\/\/\u68c0\u6d4b\u624b\u67c4\u529f\u80fd\u7684\u811a\u672c \u8fd9\u4e2a\u811a\u672c\u6302\u5230\u624b\u67c4\u4e0a\uff08controler\uff08right\uff09\u548ccontroler\uff08left\uff09\uff09\u4e0a  \r\npublic class ButtonTouchAction : MonoBehaviour {  \r\n    \/\/\u624b\u67c4  \r\n    SteamVR_TrackedObject trackdeObjec;  \r\n  \r\n    void Awake() {  \r\n        \/\/\u83b7\u53d6\u624b\u67c4\u4e0a\u7684\u8fd9\u4e2a\u7ec4\u4ef6  \r\n        trackdeObjec = GetComponent&lt;SteamVR_TrackedObject&gt;();  \r\n    }  \r\n    \/\/ Use this for initialization  \r\n    void Start () {     \r\n    }  \r\n    void FixedUpdate()  \r\n    {   \/\/\u83b7\u53d6\u624b\u67c4\u8f93\u5165  \r\n        var device = SteamVR_Controller.Input((int)trackdeObjec.index);  \r\n        \/\/\u4ee5\u4e0b\u662fapi\u4e2d\u590d\u5236\u51fa\u6765\u7684\u6309\u952e\u5217\u8868  \r\n        \/*       public class ButtonMask \r\n           { \r\n               public const ulong System = (1ul &lt;&lt; (int)EVRButtonId.k_EButton_System); \/\/ reserved \r\n               public const ulong ApplicationMenu = (1ul &lt;&lt; (int)EVRButtonId.k_EButton_ApplicationMenu); \r\n               public const ulong Grip = (1ul &lt;&lt; (int)EVRButtonId.k_EButton_Grip); \r\n               public const ulong Axis0 = (1ul &lt;&lt; (int)EVRButtonId.k_EButton_Axis0); \r\n               public const ulong Axis1 = (1ul &lt;&lt; (int)EVRButtonId.k_EButton_Axis1); \r\n               public const ulong Axis2 = (1ul &lt;&lt; (int)EVRButtonId.k_EButton_Axis2); \r\n               public const ulong Axis3 = (1ul &lt;&lt; (int)EVRButtonId.k_EButton_Axis3); \r\n               public const ulong Axis4 = (1ul &lt;&lt; (int)EVRButtonId.k_EButton_Axis4); \r\n               public const ulong Touchpad = (1ul &lt;&lt; (int)EVRButtonId.k_EButton_SteamVR_Touchpad); \r\n               public const ulong Trigger = (1ul &lt;&lt; (int)EVRButtonId.k_EButton_SteamVR_Trigger); \r\n           } \r\n           *\/  \r\n  \r\n           \/\/\u540c\u6837\u662f\u4e09\u79cd\u6309\u952e\u65b9\u5f0f\uff0c\u4ee5\u540e\u4e0d\u505a\u8d58\u8ff0  \r\n        if (device.GetTouch(SteamVR_Controller.ButtonMask.Trigger)) {  \r\n            Debug.Log(\"\u6309\u4e86 \u201ctrigger\u201d \u201c\u6273\u673a\u952e\u201d\");  \r\n             \r\n            \/\/\u53f3\u624b\u9707\u52a8  \r\n            \/\/\u62c9\u5f13\u7c7b\u4f3c\u64cd\u4f5c\u5e94\u8be5\u5c31\u662f\u6309\u4f4ftrigger\uff08\u6273\u673a\uff09gettouch\u65f6\u6301\u7eed\u8c03\u7528\u9707\u52a8\u65b9\u6cd5\u6a21\u62df\u5f13\u5f26\u7ef7\u7d27\u7684\u611f\u89c9\u3002  \r\n            var deviceIndex2 = SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.DeviceRelation.Rightmost);  \r\n            SteamVR_Controller.Input(deviceIndex2).TriggerHapticPulse(500);  \r\n  \r\n        }  \r\n        if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger))  \r\n        {   Debug.Log(\"\u6309\u4e0b\u4e86 \u201ctrigger\u201d \u201c\u6273\u673a\u952e\u201d\");  \r\n  \r\n        }  \r\n        if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger)) {  \r\n            Debug.Log(\"\u677e\u5f00\u4e86 \u201ctrigger\u201d \u201c\u6273\u673a\u952e\u201d\");  \r\n            \r\n            \/\/\u5de6\u624b\u9707\u52a8  \r\n            var deviceIndex = SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.DeviceRelation.Leftmost);  \r\n            SteamVR_Controller.Input(deviceIndex).TriggerHapticPulse(3000);  \r\n             \r\n            \/\/\u53f3\u624b\u9707\u52a8  \r\n            var deviceIndex1 = SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.DeviceRelation.Rightmost);  \r\n            SteamVR_Controller.Input(deviceIndex1).TriggerHapticPulse(3000);  \r\n        }  \r\n  \r\n        \/\/\u8fd9\u4e09\u79cd\u4e5f\u80fd\u68c0\u6d4b\u5230 \u540e\u9762\u4e0d\u505a\u8d58\u8ff0  \r\n        if(device.GetPressDown(SteamVR_Controller.ButtonMask.Trigger)) {  \r\n            Debug.Log(\"\u7528press\u6309\u4e0b\u4e86 \u201ctrigger\u201d \u201c\u6273\u673a\u952e\u201d\");  \r\n        }  \r\n        if (device.GetPress(SteamVR_Controller.ButtonMask.Trigger))  \r\n        {  \r\n            Debug.Log(\"\u7528press\u6309\u4e86 \u201ctrigger\u201d \u201c\u6273\u673a\u952e\u201d\");  \r\n        }  \r\n        if (device.GetPressUp(SteamVR_Controller.ButtonMask.Trigger))  \r\n        {  \r\n            Debug.Log(\"\u7528press\u677e\u5f00\u4e86 \u201ctrigger\u201d \u201c\u6273\u673a\u952e\u201d\");  \r\n        }  \r\n  \r\n        \/\/system\u952e \u5706\u76d8\u4e0b\u9762\u90a3\u4e2a\u952e   \r\n        \/\/ reserved \u4e3aSteam\u7cfb\u7edf\u4fdd\u7559,\u7528\u6765\u8c03\u51faSteam\u7cfb\u7edf\u83dc\u5355 \u56e0\u6b64\u8c8c\u4f3c\u81ea\u5df1\u52a0\u7684\u529f\u80fd\u6ca1\u5565\u7528  \r\n        if (device.GetTouchDown(SteamVR_Controller.ButtonMask.System))  \r\n        {  \r\n            Debug.Log(\"\u6309\u4e0b\u4e86 \u201csystem\u201d \u201c\u7cfb\u7edf\u6309\u94ae\/Steam\u201d\");  \r\n        }  \r\n        if (device.GetPressDown(SteamVR_Controller.ButtonMask.System))  \r\n        {  \r\n            Debug.Log(\"\u7528press\u6309\u4e0b\u4e86 \u201cSystem\u201d \u201c\u7cfb\u7edf\u6309\u94ae\/Steam\u201d\");  \r\n        }  \r\n  \r\n        \/\/ApplicationMenu\u952e \u5e26\u83dc\u5355\u6807\u5fd7\u7684\u90a3\u4e2a\u6309\u952e\uff08\u5728\u65b9\u5411\u5706\u76d8\u4e0a\u9762\uff09  \r\n        if (device.GetTouchDown(SteamVR_Controller.ButtonMask.ApplicationMenu))  \r\n        {  \r\n            Debug.Log(\"\u6309\u4e0b\u4e86 \u201cApplicationMenu\u201d \u201c\u83dc\u5355\u952e\u201d\");  \r\n        }  \r\n        if (device.GetPressDown(SteamVR_Controller.ButtonMask.ApplicationMenu))  \r\n        {  \r\n            Debug.Log(\"\u7528press\u6309\u4e0b\u4e86 \u201cApplicationMenu\u201d \u201c\u83dc\u5355\u952e\u201d\");  \r\n        }  \r\n  \r\n        \/\/Grip\u952e \u4e24\u4fa7\u7684\u952e \uff08vive\u96c7\u4f63\u5175\u6e38\u620f\u4e2d\u7684\u6362\u5f39\u952e\uff09\uff0c\u6bcf\u4e2a\u624b\u67c4\u5de6\u53f3\u5404\u4e00\u529f\u80fd\u76f8\u540c\uff0c\u540c\u4e00\u624b\u67c4\u4e24\u4e2a\u952e\u662f\u4e00\u4e2a\u952e\u3002  \r\n        if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Grip))  \r\n        {  \r\n            Debug.Log(\"\u6309\u4e0b\u4e86 \u201cGrip\u201d \u201c \u201d\");  \r\n        }  \r\n        if (device.GetPressDown(SteamVR_Controller.ButtonMask.Grip))  \r\n        {  \r\n            Debug.Log(\"\u7528press\u6309\u4e0b\u4e86 \u201cGrip\u201d \u201c \u201d\");  \r\n        }  \r\n  \r\n   \r\n          \r\n        \/\/Axis0\u952e \u4e0e\u5706\u76d8\u6709\u4ea4\u4e92 \u4e0e\u5706\u76d8\u6709\u5173  \r\n        \/\/\u89e6\u6478\u89e6\u53d1  \r\n        if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Axis0))  \r\n        {  \r\n            Debug.Log(\"\u6309\u4e0b\u4e86 \u201cAxis0\u201d \u201c\u65b9\u5411 \u201d\");  \r\n        }  \r\n        \/\/\u6309\u52a8\u89e6\u53d1  \r\n        if (device.GetPressDown(SteamVR_Controller.ButtonMask.Axis0))  \r\n        {  \r\n            Debug.Log(\"\u7528press\u6309\u4e0b\u4e86 \u201cAxis0\u201d \u201c\u65b9\u5411 \u201d\");  \r\n        }  \r\n  \r\n        \/\/Axis1\u952e  \u76ee\u524d\u672a\u53d1\u73b0\u6309\u952e\u4f4d\u7f6e  \r\n        \/\/\u89e6\u6478\u89e6\u53d1  \r\n        if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Axis1))  \r\n        {  \r\n            Debug.Log(\"\u6309\u4e0b\u4e86 \u201cAxis1\u201d \u201c \u201d\");  \r\n        }  \r\n        \/\/\u6309\u52a8\u89e6\u53d1   \r\n        if (device.GetPressDown(SteamVR_Controller.ButtonMask.Axis1))  \r\n        {  \r\n            Debug.Log(\"\u7528press\u6309\u4e0b\u4e86 \u201cAxis1\u201d \u201c \u201d\");  \r\n        }  \r\n  \r\n        \/\/Axis2\u952e \u76ee\u524d\u672a\u53d1\u73b0\u6309\u952e\u4f4d\u7f6e  \r\n        \/\/\u89e6\u6478\u89e6\u53d1  \r\n        if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Axis2))  \r\n        {  \r\n            Debug.Log(\"\u6309\u4e0b\u4e86 \u201cAxis2\u201d \u201c \u201d\");  \r\n        }  \r\n        \/\/\u6309\u52a8\u89e6\u53d1  \r\n        if (device.GetPressDown(SteamVR_Controller.ButtonMask.Axis2))  \r\n        {  \r\n            Debug.Log(\"\u7528press\u6309\u4e0b\u4e86 \u201cAxis2\u201d \u201c \u201d\");  \r\n        }  \r\n  \r\n        \/\/Axis3\u952e  \u672a\u76ee\u524d\u672a\u53d1\u73b0\u6309\u952e\u4f4d\u7f6e  \r\n        \/\/\u89e6\u6478\u89e6\u53d1  \r\n        if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Axis3))  \r\n        {  \r\n            Debug.Log(\"\u6309\u4e0b\u4e86 \u201cAxis3\u201d \u201c \u201d\");  \r\n        }  \r\n        \/\/\u6309\u52a8\u89e6\u53d1  \r\n        if (device.GetPressDown(SteamVR_Controller.ButtonMask.Axis3))  \r\n        {  \r\n            Debug.Log(\"\u7528press\u6309\u4e0b\u4e86 \u201cAxis3\u201d \u201c \u201d\");  \r\n        }  \r\n  \r\n        \/\/Axis4\u952e  \u76ee\u524d\u672a\u53d1\u73b0\u6309\u952e\u4f4d\u7f6e  \r\n        \/\/\u89e6\u6478\u89e6\u53d1  \r\n        if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Axis4))  \r\n        {  \r\n            Debug.Log(\"\u6309\u4e0b\u4e86 \u201cAxis4\u201d \u201c \u201d\");  \r\n        }  \r\n        \/\/\u6309\u52a8\u89e6\u53d1  \r\n        if (device.GetPressDown(SteamVR_Controller.ButtonMask.Axis4))  \r\n        {  \r\n            Debug.Log(\"\u7528press\u6309\u4e0b\u4e86 \u201cAxis4\u201d \u201c \u201d\");  \r\n        }  \r\n  \r\n&lt;pre name=\"code\" class=\"csharp\"&gt;       \/\/\u65b9\u5411\u5706\u76d8\uff1a  \r\n        \/\/\u8fd9\u91cc\u5f00\u59cb\u533a\u5206\u4e86press\u68c0\u6d4b\u4e0etouch\u68c0\u6d4b\u7684\u4e0d\u540c\u4e4b\u5904\uff0c\u5706\u76d8\u53ef\u4ee5\u89e6\u6478\uff0c\u987e\u540d\u601d\u4e49\uff0ctouch\u68c0\u6d4b\u7684\u662f\u89e6\u6478\uff0cpress\u68c0\u6d4b\u7684\u662f\u6309\u52a8&lt;pre name=\"code\" class=\"csharp\"&gt; \/\/Axis0\u952e \u4e0e\u5706\u76d8\u6709\u4ea4\u4e92 \u4e0e\u5706\u76d8\u6709\u5173  \r\n        \/\/\u89e6\u6478\u89e6\u53d1  \r\n        if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Axis0))  \r\n        {  \r\n            Debug.Log(\"\u6309\u4e0b\u4e86 \u201cAxis0\u201d \u201c\u65b9\u5411 \u201d\");  \r\n        }  \r\n        \/\/\u6309\u52a8\u89e6\u53d1  \r\n        if (device.GetPressDown(SteamVR_Controller.ButtonMask.Axis0))  \r\n        {  \r\n            Debug.Log(\"\u7528press\u6309\u4e0b\u4e86 \u201cAxis0\u201d \u201c\u65b9\u5411 \u201d\");  \r\n        }  \r\n  \r\n        \/\/Axis1\u952e  \u76ee\u524d\u672a\u53d1\u73b0\u6309\u952e\u4f4d\u7f6e  \r\n        \/\/\u89e6\u6478\u89e6\u53d1  \r\n        if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Axis1))  \r\n        {  \r\n            Debug.Log(\"\u6309\u4e0b\u4e86 \u201cAxis1\u201d \u201c \u201d\");  \r\n        }  \r\n        \/\/\u6309\u52a8\u89e6\u53d1   \r\n        if (device.GetPressDown(SteamVR_Controller.ButtonMask.Axis1))  \r\n        {  \r\n            Debug.Log(\"\u7528press\u6309\u4e0b\u4e86 \u201cAxis1\u201d \u201c \u201d\");  \r\n        }  \r\n  \r\n        \/\/Axis2\u952e \u76ee\u524d\u672a\u53d1\u73b0\u6309\u952e\u4f4d\u7f6e  \r\n        \/\/\u89e6\u6478\u89e6\u53d1  \r\n        if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Axis2))  \r\n        {  \r\n            Debug.Log(\"\u6309\u4e0b\u4e86 \u201cAxis2\u201d \u201c \u201d\");  \r\n        }  \r\n        \/\/\u6309\u52a8\u89e6\u53d1  \r\n        if (device.GetPressDown(SteamVR_Controller.ButtonMask.Axis2))  \r\n        {  \r\n            Debug.Log(\"\u7528press\u6309\u4e0b\u4e86 \u201cAxis2\u201d \u201c \u201d\");  \r\n        }  \r\n  \r\n        \/\/Axis3\u952e  \u672a\u76ee\u524d\u672a\u53d1\u73b0\u6309\u952e\u4f4d\u7f6e  \r\n        \/\/\u89e6\u6478\u89e6\u53d1  \r\n        if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Axis3))  \r\n        {  \r\n            Debug.Log(\"\u6309\u4e0b\u4e86 \u201cAxis3\u201d \u201c \u201d\");  \r\n        }  \r\n        \/\/\u6309\u52a8\u89e6\u53d1  \r\n        if (device.GetPressDown(SteamVR_Controller.ButtonMask.Axis3))  \r\n        {  \r\n            Debug.Log(\"\u7528press\u6309\u4e0b\u4e86 \u201cAxis3\u201d \u201c \u201d\");  \r\n        }  \r\n  \r\n        \/\/Axis4\u952e  \u76ee\u524d\u672a\u53d1\u73b0\u6309\u952e\u4f4d\u7f6e  \r\n        \/\/\u89e6\u6478\u89e6\u53d1  \r\n        if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Axis4))  \r\n        {  \r\n            Debug.Log(\"\u6309\u4e0b\u4e86 \u201cAxis4\u201d \u201c \u201d\");  \r\n        }  \r\n        \/\/\u6309\u52a8\u89e6\u53d1  \r\n        if (device.GetPressDown(SteamVR_Controller.ButtonMask.Axis4))  \r\n        {  \r\n            Debug.Log(\"\u7528press\u6309\u4e0b\u4e86 \u201cAxis4\u201d \u201c \u201d\");  \r\n        }  \r\n  \r\n  \r\n        \/\/ATouchpad\u952e \u5706\u76d8\u4ea4\u4e92  \r\n        \/\/\u89e6\u6478\u89e6\u53d1  \r\n        if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Touchpad))  \r\n        {     \r\n            Debug.Log(\"\u6309\u4e0b\u4e86 \u201cTouchpad\u201d \u201c \u201d\");  \r\n              \r\n            \/\/\u65b9\u6cd5\u8fd4\u56de\u4e00\u4e2a\u5750\u6807 \u63a5\u89e6\u5706\u76d8\u4f4d\u7f6e  \r\n            Vector2 cc = device.GetAxis();  \r\n            Debug.Log(cc);  \r\n            \/\/ \u4f8b\u5b50\uff1a\u5706\u76d8\u5206\u6210\u4e0a\u4e0b\u5de6\u53f3  \r\n            float jiaodu = VectorAngle(new Vector2(1, 0), cc);  \r\n            Debug.Log(jiaodu);  \r\n            \/\/\u4e0b  \r\n            if (jiaodu &gt; 45 &amp;&amp; jiaodu &lt; 135)  \r\n            {  \r\n                Debug.Log(\"\u4e0b\");  \r\n            }  \r\n            \/\/\u4e0a  \r\n            if (jiaodu &lt; -45 &amp;&amp; jiaodu &gt; -135)  \r\n            {  \r\n                Debug.Log(\"\u4e0a\");  \r\n            }  \r\n            \/\/\u5de6  \r\n            if ((jiaodu &lt; 180 &amp;&amp; jiaodu &gt; 135) || (jiaodu &lt; -135 &amp;&amp; jiaodu &gt; -180))  \r\n            {  \r\n                Debug.Log(\"\u5de6\");  \r\n            }  \r\n            \/\/\u53f3  \r\n            if ((jiaodu &gt; 0 &amp;&amp; jiaodu &lt; 45) || (jiaodu &gt; -45 &amp;&amp; jiaodu &lt; 0))  \r\n            {  \r\n                Debug.Log(\"\u53f3\");  \r\n            }  \r\n        }  \r\n        \/\/\u6309\u52a8\u89e6\u53d1  \r\n        if (device.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad))  \r\n        {  \r\n            Debug.Log(\"\u7528press\u6309\u4e0b\u4e86 \u201cTouchpad\u201d \u201c \u201d\");  \r\n        }  \r\n  \r\n         \r\n  \r\n  \r\n  \r\n    }  \r\n        \/\/ Update is called once per frame  \r\n        void Update () {  \r\n      \r\n    }  \r\n    \/\/\u65b9\u5411\u5706\u76d8\u6700\u597d\u914d\u5408\u8fd9\u4e2a\u4f7f\u7528 \u5706\u76d8\u7684.GetAxis()\u4f1a\u68c0\u6d4b\u8fd4\u56de\u4e00\u4e2a\u4e8c\u4f4d\u5411\u91cf\uff0c\u53ef\u7528\u89d2\u5ea6\u5212\u5206\u5706\u76d8\u6309\u952e\u6570\u91cf  \r\n    \/\/\u8fd9\u4e2a\u51fd\u6570\u8f93\u5165\u4e24\u4e2a\u4e8c\u7ef4\u5411\u91cf\u4f1a\u8fd4\u56de\u4e00\u4e2a\u5939\u89d2 180 \u5230 -180  \r\n    float VectorAngle(Vector2 from, Vector2 to)  \r\n    {  \r\n        float angle;  \r\n        Vector3 cross = Vector3.Cross(from, to);  \r\n        angle = Vector2.Angle(from, to);  \r\n        return cross.z &gt; 0 ? -angle : angle;  \r\n    }  \r\n}<\/pre>\n<p>&nbsp;<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u8f6c\u81ea\uff1ahttp:\/\/www.cnblogs.com\/czaoth\/p\/561 &hellip; <a href=\"http:\/\/www.u3d8.com\/?p=568\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[159,160,158],"_links":{"self":[{"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/posts\/568"}],"collection":[{"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=568"}],"version-history":[{"count":2,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/posts\/568\/revisions"}],"predecessor-version":[{"id":718,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/posts\/568\/revisions\/718"}],"wp:attachment":[{"href":"http:\/\/www.u3d8.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=568"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=568"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=568"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}