Browse Source

修复锚点位置变化bug

蓝色星空 1 year ago
parent
commit
34dcb02da1

+ 14 - 0
Assets/Script/GongShi2.cs

@@ -1,5 +1,6 @@
 using System.Collections;
 using System.Collections.Generic;
+using Blue;
 using UnityEngine;
 using UnityEngine.UI;
 
@@ -73,6 +74,7 @@ public class GongShi2 : MonoBehaviour
         WebPosObj2= go3;
         WebPosObj.transform.parent = parent.parent;
         WebPosObj2.transform.parent = parent.parent;
+        CommandSystem.Instance.Send(new InitSuccessCommand());
     }
 
 
@@ -93,3 +95,15 @@ public class GongShi2 : MonoBehaviour
         return lvlist;
     }
 }
+
+public struct InitEvent:IEvent
+{
+
+}
+public struct InitSuccessCommand : ICommand
+{
+    public void OnExcute()
+    {
+        this.SendEvent<InitEvent>();
+    }
+}

+ 20 - 3
Assets/Scripts/Blue/Controller/LoadReference.cs

@@ -6,16 +6,33 @@ public class LoadReference : AbstractController
     public GameObject goRefrence;
     private Transform meshTest=>(SceneIOCContainer.Instance.Pull("mesh_test")as GameObject).transform;
     private Transform meshTestParent=>(SceneIOCContainer.Instance.Pull("ARSpaceForAll")as GameObject).transform;
+
+    private bool bool_GetReferencePosEvent=false;
+    private bool bool_InitEvent=false;
+    private Vector3 pos;
     private void Start()
     {
         this.RegisterEvent<GetReferencePosEvent>(GetObjOfRefrencePosRotSuccess).UnRegisterWhenGameObjectDestroyed(gameObject);
+        this.RegisterEvent<InitEvent>(InitEventSuccess).UnRegisterWhenGameObjectDestroyed(gameObject);
     }
 
     private void GetObjOfRefrencePosRotSuccess(GetReferencePosEvent e)
     {
-        Vector3 pos = new Vector3(e.PosRot.x, e.PosRot.y, e.PosRot.z);
-        SetPosRot(pos);
-        //Debug.Log("参考物坐标:"+pos);
+        bool_GetReferencePosEvent = true;
+        pos = new Vector3(e.PosRot.x, e.PosRot.y, e.PosRot.z);
+
+        if(bool_GetReferencePosEvent && bool_InitEvent)
+        {
+            SetPosRot(pos);
+        }
+    }
+    private void InitEventSuccess(InitEvent e)
+    {
+        bool_InitEvent = true;
+        if(bool_GetReferencePosEvent && bool_InitEvent)
+        {
+            SetPosRot(pos);
+        }
     }
 
     private void SetPosRot(Vector3 pos)

+ 2 - 2
Assets/Scripts/Blue/Service/IMinMapService.cs

@@ -56,7 +56,7 @@ public class MinMapService : IMinMapService
             }
             else
             {
-                Debug.LogError(webRequest.downloadHandler.text);
+                //Debug.LogError(webRequest.downloadHandler.text);
                 if (!string.IsNullOrWhiteSpace(webRequest.downloadHandler.text))
                 {
                     message = webRequest.downloadHandler.text;
@@ -64,7 +64,7 @@ public class MinMapService : IMinMapService
                     if (jobject["code"].ToString() == "200")
                     {
                         message = jobject["data"].ToString();
-                        Debug.LogError(message);
+                        //Debug.LogError(message);
                         if (!string.IsNullOrWhiteSpace(message))
                         {
                             GetUserInfo getUserInfo =  JsonConvert.DeserializeObject<GetUserInfo>(message);