Explorar o código

手势退出+模拟鼠标灵敏度+模块方向修改

lvjincheng %!s(int64=3) %!d(string=hai) anos
pai
achega
6f5f229316

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

@@ -330,7 +330,11 @@ public class AimHandler : MonoBehaviour
             Acc = new Vector3(-az, ax, -ay) / 32768 * 16;
             Gyr = new Vector3(-yaw, roll, -pitch) / 32768 * 2;
             Mag = new Vector3(mzr, mxr, -myr) / 32768 * 256;//第二个6+3硬件
-        } 
+        } else if (CommonConfig.devicePlan == 3) {
+            Acc = new Vector3(az, ay, ax) / 32768 * 16;
+            Gyr = new Vector3(-yaw, -pitch, -roll) / 32768 * 2;
+            Mag = new Vector3(z, y, -x) / 32768 * 256; //最新版
+        }
 
         AccObj.transform.GetChild(0).localPosition = Acc;
 

+ 1 - 1
Assets/BowArrow/Scripts/CommonConfig.cs

@@ -19,7 +19,7 @@ public class CommonConfig
     public static bool isReleaseVersion = false;
 
     //设备方案
-    public static readonly int devicePlan = 0;
+    public static readonly int devicePlan = 3;
 
     /**环数精度小数位 */
     public static readonly int ringsPrecision = 1;

+ 39 - 1
Assets/BowArrow/Scripts/Entry.cs

@@ -21,7 +21,7 @@ public class Entry : MonoBehaviour
         // Application.targetFrameRate = 60;
         QualitySettings.vSyncCount = 1;
         // SetTip("Loading", Color.white, 56);
-        versionText.text = "Version_" + appVersion + "_R5";
+        versionText.text = "Version_" + appVersion + "_R6";
         //SetTip("正在检测对比软件版本", Color.white);
         StartCoroutine(CheckAppVersion());
         StartCoroutine(AsyncLoadScene());
@@ -33,6 +33,8 @@ public class Entry : MonoBehaviour
             long t2 = JC.CS.Utility.GetTimestamp();
             Debug.Log($"场景{scene.name}销毁,释放资源和GC回收的总耗时={t2 - t1}ms");
         };
+
+        PersistenHandler.Init();
     }
 
     [SerializeField] Text versionText;
@@ -40,49 +42,74 @@ public class Entry : MonoBehaviour
     bool appVersionCheckOK = false;
 
     IEnumerator CheckAppVersion() {
+        countStr1 += "a";
         string url = CommonConfig.businessServerURI + "/app/checkAppVersion?appVersion=" + appVersion;
+        countStr1 += "b";
         using (UnityWebRequest request = UnityWebRequest.Get(url)) {
+            countStr1 += "c";
             yield return request.SendWebRequest();
+            countStr1 += "d";
             if (request.result == UnityWebRequest.Result.Success) {
+                countStr1 += "e";
                 appVersionCheckOK = bool.Parse(request.downloadHandler.text);
+                countStr1 += "f";
                 if (appVersionCheckOK) {
+                    countStr1 += "g";
                     //等场景加载完再提示
                 } else {
+                    countStr1 += "h";
                     SetTip("请安装最新版本软件", Color.yellow);
                     DelayQuit();
                 }
             } else {
+                countStr1 += "i";
                 SetTip("读取服务端软件版本配置失败", Color.red);
                 DelayQuit();
             }
+            countStr1 += "j";
         }
+        countStr1 += "k";
+        Debug.Log("countStr1:" + countStr1);
     }
 
     float timeOnStartLoadScene;
     IEnumerator AsyncLoadScene() {
+        countStr2 += "a";
         timeOnStartLoadScene = Time.realtimeSinceStartup;
         //加载场景名
         string sceneName = "Login";
         if (LoginMgr.HasToken()) {
             sceneName = "Home";
         }
+        countStr2 += sceneName;
         //异步加载场景
         AsyncOperation async = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Single);
+        countStr2 += "b";
         //阻止当加载完成自动切换
         async.allowSceneActivation = false;
+        countStr2 += "c";
         while (!async.isDone) {
             if (async.progress >= 0.9f) {
+                countStr2 += "e";
                 break;
             }
+            if (!countStr2.Contains("d")) countStr2 += "d";
             yield return null;
         }
+        countStr2 += "f";
         while (!appVersionCheckOK) {
+            if (!countStr2.Contains("@")) countStr2 += "@";
             yield return null;
         }
+        countStr2 += "g";
         while (Time.realtimeSinceStartup - timeOnStartLoadScene < 1.5) {
+            if (!countStr2.Contains("%")) countStr2 += "%";
             yield return null;
         }
+        countStr2 += "h";
         async.allowSceneActivation = true;
+        countStr2 += "i";
+        Debug.Log("countStr2:" + countStr2);
         //SetTip("软件版本校验成功", Color.green);
     }
 
@@ -98,4 +125,15 @@ public class Entry : MonoBehaviour
             Application.Quit();
         });
     }
+
+    int counter = 0;
+    string countStr1 = "";
+    string countStr2 = "";
+    void OnGUI()  
+    {  
+        GUIStyle labelFont = new GUIStyle();
+        labelFont.normal.textColor = new Color(1, 0.6f, 0.6f); 
+        labelFont.fontSize = 40; 
+        GUI.Label(new Rect(Screen.width/10,Screen.height/10,200,200), (counter++) + "," + countStr1 + "," + countStr2, labelFont);  
+    }
 }

+ 31 - 0
Assets/BowArrow/Scripts/Expand/PersistenHandler.cs

@@ -0,0 +1,31 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+//持久化的处理脚本,在app启动时就应开始常驻
+public class PersistenHandler : MonoBehaviour
+{
+    public static PersistenHandler ins;
+
+    public static void Init() {
+        if (ins) return;
+        GameObject obj = new GameObject("PersistenHandler");
+        ins = obj.AddComponent<PersistenHandler>();
+        DontDestroyOnLoad(obj);
+    }
+
+    long lastPressExitTime = 0;
+
+    void Update()
+    {
+        if (Input.GetKeyDown(KeyCode.Escape)) {
+            long lastLast = lastPressExitTime;
+            lastPressExitTime = JC.CS.Utility.GetTimestamp();
+            if (lastPressExitTime - lastLast < 10 * 1000) {
+                Application.Quit();
+            } else {
+                PopupMgr.ins.ShowTip("再按一次退出APP");
+            }
+        }
+    }
+}

+ 11 - 0
Assets/BowArrow/Scripts/Expand/PersistenHandler.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: a5d671f5d985acc40825b35effb1e195
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

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

@@ -121,8 +121,8 @@ public class SB_EventSystem : MonoBehaviour
                 Vector3 lastAngle = nowAxisQuat.eulerAngles;
                 nowAxisQuat = Quaternion.Lerp(nowAxisQuat, targetAxisQuat, 0.033f * 8);
                 Vector3 curAngle = nowAxisQuat.eulerAngles;
-                float dx = FormatDeltaAngleY(curAngle.y - lastAngle.y) / 60f * simulateMouse.GetScaleScreenWidth();
-                float dy = -FormatDeltaAngleX(curAngle.x - lastAngle.x) / 40f * simulateMouse.GetScaleScreenHeight();
+                float dx = FormatDeltaAngleY(curAngle.y - lastAngle.y) / 20f * simulateMouse.GetScaleScreenWidth();
+                float dy = -FormatDeltaAngleX(curAngle.x - lastAngle.x) / 14f * simulateMouse.GetScaleScreenHeight();
                 deltaVectorForMouse.x = dx;
                 deltaVectorForMouse.y = dy;
                 simulateMouse.MoveMousePointer(deltaVectorForMouse);