Ver código fonte

添加移动功能

ZXP 1 ano atrás
pai
commit
81bc305b68

+ 0 - 22
Assets/Scenes/Main.unity

@@ -9720,7 +9720,6 @@ GameObject:
   - component: {fileID: 745471950}
   - component: {fileID: 745471953}
   - component: {fileID: 745471952}
-  - component: {fileID: 745471951}
   - component: {fileID: 4080943174512973282}
   m_Layer: 5
   m_Name: Help2 (1)
@@ -9753,27 +9752,6 @@ RectTransform:
   m_AnchoredPosition: {x: -28.73, y: 0}
   m_SizeDelta: {x: 3897.8965, y: 1397}
   m_Pivot: {x: 0.5, y: 0.5}
---- !u!114 &745471951
-MonoBehaviour:
-  m_ObjectHideFlags: 0
-  m_CorrespondingSourceObject: {fileID: 0}
-  m_PrefabInstance: {fileID: 0}
-  m_PrefabAsset: {fileID: 0}
-  m_GameObject: {fileID: 745471949}
-  m_Enabled: 1
-  m_EditorHideFlags: 0
-  m_Script: {fileID: 11500000, guid: 0bb5e4d934d798343a34c26749cec382, type: 3}
-  m_Name: 
-  m_EditorClassIdentifier: 
-  loginGameObject: {fileID: 0}
-  tj1: {fileID: 0}
-  tj2: {fileID: 0}
-  id: 
-  key: 
-  startPoint: {x: 0, y: 0, z: 0}
-  startVector: {x: 0, y: 0, z: 0}
-  endPoint: {x: 0, y: 0, z: 0}
-  endVecotr: {x: 0, y: 0, z: 0}
 --- !u!114 &745471952
 MonoBehaviour:
   m_ObjectHideFlags: 0

+ 36 - 4
Assets/Scripts/Login.cs

@@ -8,6 +8,7 @@ using System.Text.RegularExpressions;
 using System.Security.Cryptography;
 using System.Text;
 using UnityEngine.Networking;
+using UnityEngine.XR;
 
 public class Login : SingletonBaseMono<Login>
 {
@@ -20,10 +21,10 @@ public class Login : SingletonBaseMono<Login>
     private static long Jan1st1970Ms = new DateTime(1970, 1, 1, 0, 0, 0, System.DateTimeKind.Utc).Ticks;
 
     [Header("朝向学生视角")]
-    public Vector3 startPoint ;
+    public Vector3 startPoint;
     public Vector3 startVector;
     [Header("朝向黑板视角")]
-    public Vector3 endPoint ;
+    public Vector3 endPoint;
     public Vector3 endVecotr;
 
     private string phoneNumber;
@@ -33,15 +34,46 @@ public class Login : SingletonBaseMono<Login>
     private string firseState;
 
     private Action<string> sendListCallBack;
+
+    private InputDevice leftHandController;
+    private InputDevice rightHandController;
+
     void Start()
     {
-
+        leftHandController = InputDevices.GetDeviceAtXRNode(XRNode.LeftHand);
+        rightHandController = InputDevices.GetDeviceAtXRNode(XRNode.RightHand);
     }
 
     // Update is called once per frame
     void Update()
     {
-        //Debug.Log(phoneNumber);
+        Vector2 axis;
+        if (leftHandController.TryGetFeatureValue(CommonUsages.primary2DAxis, out axis))
+        {
+            transform.Translate(new Vector3(axis.x, 0, axis.y) * Time.deltaTime);
+        }
+        if (rightHandController.TryGetFeatureValue(CommonUsages.primary2DAxis, out axis))
+        {
+            transform.Translate(new Vector3(axis.x, 0, axis.y) * Time.deltaTime);
+        }
+        if (transform.position.x < -5)
+        {
+            transform.position = new Vector3(-5, transform.position.y, transform.position.z);
+        }
+        if (transform.position.x > 5)
+        {
+            transform.position = new Vector3(5, transform.position.y, transform.position.z);
+        }
+        if (transform.position.z < -10)
+        {
+            transform.position = new Vector3(transform.position.x, transform.position.y, -10);
+        }
+        if (transform.position.z > 10)
+        {
+            transform.position = new Vector3(transform.position.x, transform.position.y, 10);
+        }
+
+        Debug.Log(axis);
     }
 
     /// <summary>

+ 4 - 1
ProjectSettings/ProjectSettings.asset

@@ -140,7 +140,10 @@ PlayerSettings:
     16:9: 1
     Others: 1
   bundleVersion: 0.1
-  preloadedAssets: []
+  preloadedAssets:
+  - {fileID: 11400000, guid: 71609cae5115a9c48a55d69900e47fa4, type: 2}
+  - {fileID: 11400000, guid: 9953094977e9c214abbe81577a8ebb24, type: 2}
+  - {fileID: 1029437730009618294, guid: 46af8c7be485534469cb459b30031684, type: 2}
   metroInputSource: 0
   wsaTransparentSwapchain: 0
   m_HolographicPauseOnTrackingLoss: 1

粤ICP备19079148号