Ver Fonte

鼠标激活时居中去掉

lvjincheng há 3 anos atrás
pai
commit
dda9d985cd

+ 1 - 2
Assets/BowArrow/Scripts/Bluetooth/AimHandler.cs

@@ -253,8 +253,7 @@ public class AimHandler : MonoBehaviour
                     if (SB_EventSystem.ins && SB_EventSystem.ins.simulateMouseIsAwaked) {
                         //视角回正
                         DoIdentity();
-                        //鼠标居中
-                        SB_EventSystem.ins.MakeMouseToScreenCenter(newRotation);
+                        //鼠标居中自然会居中
                     } else {
                         AutoResetView.DoIdentity();
                     }

+ 2 - 18
Assets/BowArrow/Scripts/Expand/SB_EventSystem.cs

@@ -53,9 +53,6 @@ public class SB_EventSystem : MonoBehaviour
         [System.NonSerialized] public bool simulateMouseIsAwaked;
         public void AwakenSimulateMouse() {
             simulateMouseIsAwaked = !simulateMouse.gameObject.activeSelf;
-            if (simulateMouseIsAwaked && AimHandler.ins) {
-                MakeMouseToScreenCenter(AimHandler.ins.newRotation);
-            }
             simulateMouse.gameObject.SetActive(simulateMouseIsAwaked);
              try { 
                 GlobalEventCenter.ins.onSimulateMouseAwakeChanged?.Invoke(simulateMouseIsAwaked); 
@@ -64,17 +61,10 @@ public class SB_EventSystem : MonoBehaviour
     #endregion 鼠标激活/关闭
 
     #region 模拟鼠标移动
-        Vector3 identityEulerAngles;
-        Quaternion nowAxisQuat;
+        Quaternion nowAxisQuat = Quaternion.identity;
         Quaternion newAxisQuat;
         Vector2 mousePointerPosition;
-        bool hasDoIdentity = false; //用于一开始会自当校准一次
         public void MoveSimulateMouse(Quaternion axisQuat) {
-            if (!hasDoIdentity) {
-                hasDoIdentity = true;
-                AimHandler.ins.DoIdentity();
-                MakeMouseToScreenCenter(AimHandler.ins.newRotation);
-            }
             if (IsClickMouseCooling()) { //点击就是射出,射出会产生抖动,防止接收抖动后的数据
                 return;
             } 
@@ -83,7 +73,7 @@ public class SB_EventSystem : MonoBehaviour
         void UpdateMoveSimulateMouse() {
             if (!simulateMouseIsAwaked) return;
             nowAxisQuat = Quaternion.Lerp(nowAxisQuat, newAxisQuat, 0.033f * 8);
-            Vector3 resEulerAngles = FormatQuat(nowAxisQuat).eulerAngles - identityEulerAngles;
+            Vector3 resEulerAngles = FormatQuat(nowAxisQuat).eulerAngles;
             resEulerAngles.x = Mathf.Clamp(resEulerAngles.x > 180 ? resEulerAngles.x - 360 : resEulerAngles.x, -12.5f, 12.5f);
             resEulerAngles.y = Mathf.Clamp(resEulerAngles.y > 180 ? resEulerAngles.y - 360 : resEulerAngles.y, -22.2f, 22.2f);
             mousePointerPosition.x = (resEulerAngles.y + 22.2f) / 44.4f * Screen.width;
@@ -96,12 +86,6 @@ public class SB_EventSystem : MonoBehaviour
         }
     #endregion 模拟鼠标移动
 
-    //鼠标居中
-    public void MakeMouseToScreenCenter(Quaternion identityQuaternion) {
-        identityEulerAngles = FormatQuat(identityQuaternion).eulerAngles;
-        nowAxisQuat = identityQuaternion;
-    }
-
     //点击鼠标
     float _lastClickMouseTime = -100;
     void RecordClickMouseTime() {