Browse Source

修改移动场景时关闭定位逻辑

蓝色星空 1 year ago
parent
commit
e5ffb5afc4

+ 22 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Util/SingletonPatch.cs

@@ -0,0 +1,22 @@
+namespace Blue
+{
+    /// <summary>
+    /// 单例模式的基类
+    /// </summary>
+    public class SingletonPatch<T> where T : SingletonPatch<T>, new()
+    {
+        private static T instance;
+
+        public static T Instance
+        {
+            get
+            {
+                if (instance == null)
+                {
+                    instance = new T();
+                }
+                return instance;
+            }
+        }
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Util/SingletonPatch.cs.meta

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

+ 1 - 1
Assets/Scripts/Blue/Controller/ImmersalLocalizerController.cs

@@ -25,7 +25,7 @@ public class ImmersalLocalizerController: AbstractController
     {
         time += Time.deltaTime;
 
-        if(time > rateTime  && startLocalizer)
+        if(time > rateTime  && startLocalizer && !SetSceneActive.Instance.active)
         {
             XRLocalizer.Localize();
             time= 0;

+ 2 - 9
Assets/Scripts/Blue/Controller/SavePanel.cs

@@ -12,7 +12,6 @@ public class SavePanel : AbstractController
     public Transform meshTest;
     public Transform parent;
     public SCToggleSwitch3D sCToggleSwitch3D;
-    [SerializeField] private GameObject ARMap;
 
     private List<ScenePosRotInfo> posRotlist = new List<ScenePosRotInfo>();
     private ScenePosRotInfo pos = new ScenePosRotInfo();
@@ -22,8 +21,6 @@ public class SavePanel : AbstractController
         posRotlist.Add(pos); posRotlist.Add(rot);
         meshTest = GameObject.Find("ARSpaceForAll/mesh_test").gameObject.transform;
         parent = GameObject.Find("ARSpaceForAll").transform;
-        ARMap = GameObject.Find("ARSpaceForAll/AR_Map");
-        ARMap.SetActive(false);
         sCToggleSwitch3D = transform.parent.GetComponent<SCToggleSwitch3D>();
 
         saveBtn.onClick.AddListener(Save);
@@ -69,14 +66,10 @@ public class SavePanel : AbstractController
 
     private void OnEnable()
     {
-        if(ARMap!=null)
-            ARMap.SetActive(false);
-        SetSceneActive.active = true;
+        SetSceneActive.Instance.active = true;
     }
     private void OnDisable()
     {
-        if(ARMap!=null)
-            ARMap.SetActive(true);
-        SetSceneActive.active = false;
+        SetSceneActive.Instance.active = false;
     }
 }

+ 4 - 2
Assets/Scripts/Blue/Model/SetSceneActive.cs

@@ -1,4 +1,6 @@
-public static class SetSceneActive
+using Blue;
+
+public class SetSceneActive : SingletonPatch<SetSceneActive>
 {
-    public static bool active = false;
+    public bool active = false;
 }

+ 2 - 2
Assets/Scripts/Blue/Temp/MoveChange.cs

@@ -34,7 +34,7 @@ public class MoveChange : MonoBehaviour
         {
             return;
         }
-        if (!SetSceneActive.active)
+        if (!SetSceneActive.Instance.active)
             return;
         Debug.Log("keyUpEventDelegate===>" + keyCode);
 #if UNITY_EDITOR
@@ -64,7 +64,7 @@ public class MoveChange : MonoBehaviour
 
     void Update()
     {
-        if (isDown && SetSceneActive.active)
+        if (isDown && SetSceneActive.Instance.active)
         {
             moveGame.transform.eulerAngles = new Vector3(0, moveGame.transform.eulerAngles.y, 0);
             moveGame.transform.position = new Vector3(moveGame.transform.position.x, y, moveGame.transform.position.z);