Bladeren bron

离开触发区域保存不重置

蓝色星空 1 jaar geleden
bovenliggende
commit
b909fb84aa

+ 13 - 0
Assets/Scripts/Blue/Other/PosRotScale.cs

@@ -0,0 +1,13 @@
+using UnityEngine;
+using System.Collections.Generic;
+
+public static class PosRotScale
+{
+    public static List<PosRotScalePatch> PosRotScalePatchList = new List<PosRotScalePatch>();
+}
+public class PosRotScalePatch
+{
+    public Vector3 PosPatch;
+    public Vector3 RotPatch;
+    public Vector3 ScalePatch;
+}

+ 11 - 0
Assets/Scripts/Blue/Other/PosRotScale.cs.meta

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

+ 2 - 1
Assets/Scripts/Net/HttpTool.cs

@@ -16,7 +16,8 @@ public class HttpTool : MonoSingleton<HttpTool>
 {
 
   //  private string baseUrl = "http://office.ghz-tech.com:3425/guideSystem";
-    private string baseUrl = "http://office.ghz-tech.com:9904/api";
+    //private string baseUrl = "http://office.ghz-tech.com:9904/api";
+    private string baseUrl = "https://nav21.ghz-tech.com:8843/api/";
     private string token = "";
     Dictionary<string, string> requestHeader = new Dictionary<string, string>();  //  header
     void Awake()

+ 3 - 3
Assets/Scripts/UI/EdirPanel/MaterialBtnItem.cs

@@ -108,9 +108,9 @@ public class MaterialBtnItem : MonoBehaviour, EventObserver
         m_ObjectValue = objValue;
         MaterialObj = objValue.Object;
         m_Text.text = string.IsNullOrWhiteSpace(value.name) ? MaterialObj.name : value.name;
-        MaterialObj.transform.localPosition = m_ObjectValue.nowPos;
-        MaterialObj.transform.localEulerAngles = m_ObjectValue.nowRot;
-        MaterialObj.transform.localScale = m_ObjectValue.nowScale;
+        //MaterialObj.transform.localPosition = m_ObjectValue.nowPos;
+        //MaterialObj.transform.localEulerAngles = m_ObjectValue.nowRot;
+        //MaterialObj.transform.localScale = m_ObjectValue.nowScale;
 
         //m_Image.sprite = 
     }

+ 24 - 11
Assets/Scripts/UI/EdirPanel/UIEditorPanel.cs

@@ -216,6 +216,8 @@ public class UIEditorPanel : MonoBehaviour, EventObserver
 
         RevocationBtn.onClick.AddListener(() =>
         {
+            GameManager.Instance.SetPosRotScale();
+
             if (MaterialObj == null)
                 return;
 
@@ -235,6 +237,9 @@ public class UIEditorPanel : MonoBehaviour, EventObserver
                 return;
             GameManager.Instance.SaveSpoitObjs();
             */
+
+            // TODO 需要再保存一次
+            GameManager.Instance.GetPosRotScale();
             StartCoroutine(SetSpoitInfo());
         });
     }
@@ -245,20 +250,28 @@ public class UIEditorPanel : MonoBehaviour, EventObserver
         int count = GameManager.Instance.ObjsParent.childCount;
         for (int i = initCount; i <= count-1;i++) // 第一个LocalNULLShowObj是无用的
         {
-            var spoit = GameManager.Instance.SpoitValues[i-initCount]; // 某个景点
-
-            for (int j = 0; j < spoit.material.Count; j++) // 更新 ObjectTransform
+            for (int temp = 0; temp < GameManager.Instance.ColliderObjectValues.Count;temp++)
             {
-                for (int k = 0;k< spoit.material[j].materialList.Count; k++)
+                // 判断景点是否是场景景点名字
+                if(GameManager.Instance.ColliderObjectValues[temp].matName==GameManager.Instance.ObjsParent.GetChild(i).name)
                 {
-                    spoit.material[j].select = true;
-                    spoit.material[j].materialList[k].ObjectTransform.nowPos = GameManager.Instance.ObjsParent.GetChild(i).GetChild(j).GetChild(k).localPosition;
-                    spoit.material[j].materialList[k].ObjectTransform.nowRot = GameManager.Instance.ObjsParent.GetChild(i).GetChild(j).GetChild(k).localEulerAngles;
-                    spoit.material[j].materialList[k].ObjectTransform.nowScale = GameManager.Instance.ObjsParent.GetChild(i).GetChild(j).GetChild(k).localScale;
+                    Debug.LogError(GameManager.Instance.ObjsParent.GetChild(i).name);
+                    var spoit = GameManager.Instance.SpoitValues[i-initCount]; // 某个景点
+
+                    for (int j = 0; j < spoit.material.Count; j++) // 更新 ObjectTransform
+                    {
+                        for (int k = 0;k< spoit.material[j].materialList.Count; k++)
+                        {
+                            spoit.material[j].select = true;
+                            spoit.material[j].materialList[k].ObjectTransform.nowPos = GameManager.Instance.ObjsParent.GetChild(i).GetChild(j).GetChild(k).localPosition;
+                            spoit.material[j].materialList[k].ObjectTransform.nowRot = GameManager.Instance.ObjsParent.GetChild(i).GetChild(j).GetChild(k).localEulerAngles;
+                            spoit.material[j].materialList[k].ObjectTransform.nowScale = GameManager.Instance.ObjsParent.GetChild(i).GetChild(j).GetChild(k).localScale;
+                        }
+                    }
+                    SplitSpoitData(spoit,count-initCount); //// 第一个LocalNULLShowObj是无用的 ,so -1
+                    yield return null;
                 }
             }
-            SplitSpoitData(spoit,count-initCount); //// 第一个LocalNULLShowObj是无用的 ,so -1
-            yield return null;
         }
     }
     private List<SendSaveData> saveData = new List<SendSaveData>();
@@ -274,7 +287,7 @@ public class UIEditorPanel : MonoBehaviour, EventObserver
         saveData.Add(data);
 
         string sendData = JsonConvert.SerializeObject(saveData);
-        Debug.LogError(countSplit+"=="+spoitCount);
+        //Debug.LogError(countSplit+"=="+spoitCount);
         if(countSplit==spoitCount)
             HttpTool.Instance.PostTest("/viewpoint/update", sendData, SaveCallBack);
     }

+ 47 - 0
Assets/Scripts/UI/GameManager.cs

@@ -425,6 +425,7 @@ public class GameManager : MonoSingleton<GameManager>
 
         if (ison)
         {
+            GetPosRotScale(); // 获取所有物体位置旋转缩放
             m_EditorCanvas.position = API_GSXR_Slam.GSXR_Get_Head().position + Player.transform.forward + new Vector3(0, 0.5f, 0);
             m_EditorCanvas.eulerAngles = new Vector3(0, API_GSXR_Slam.GSXR_Get_Head().eulerAngles.y, 0);
 
@@ -432,6 +433,7 @@ public class GameManager : MonoSingleton<GameManager>
         }
         else
         {
+            SetPosRotScale();// 设置所有物体位置旋转缩放
             m_EditorCanvas.position = API_GSXR_Slam.GSXR_Get_Head().position + new Vector3(0, 100, 0);
 
             if (SpoitIndex >= 0 && !IsTriggerExiting)
@@ -481,6 +483,51 @@ public class GameManager : MonoSingleton<GameManager>
         }
 
     }
+
+    public void GetPosRotScale()
+    {
+        PosRotScale.PosRotScalePatchList.Clear();
+        for (int i = 0; i < GameManager.Instance.ObjsParent.childCount; i++)
+        {
+            if (i != 0)
+            {
+                for (int j = 0; j < GameManager.Instance.ObjsParent.GetChild(i).childCount; j++)
+                {
+                    for (int k = 0; k < GameManager.Instance.ObjsParent.GetChild(i).GetChild(j).childCount; k++)
+                    {
+                        PosRotScalePatch PosRotScalePatch = new PosRotScalePatch();
+                        PosRotScalePatch.PosPatch = GameManager.Instance.ObjsParent.GetChild(i).GetChild(j).GetChild(k).localPosition;
+                        PosRotScalePatch.RotPatch = GameManager.Instance.ObjsParent.GetChild(i).GetChild(j).GetChild(k).localEulerAngles;
+                        PosRotScalePatch.ScalePatch = GameManager.Instance.ObjsParent.GetChild(i).GetChild(j).GetChild(k).localScale;
+                        PosRotScale.PosRotScalePatchList.Add(PosRotScalePatch);
+                    }
+                }
+            }
+        }
+    }
+    public void SetPosRotScale()
+    {
+        if (PosRotScale.PosRotScalePatchList.Count != 0)
+        {
+            int temp = 0;
+            for (int i = 0; i < GameManager.Instance.ObjsParent.childCount; i++)
+            {
+                if (i != 0)
+                {
+                    for (int j = 0; j < GameManager.Instance.ObjsParent.GetChild(i).childCount; j++)
+                    {
+                        for (int k = 0; k < GameManager.Instance.ObjsParent.GetChild(i).GetChild(j).childCount; k++)
+                        {
+                            GameManager.Instance.ObjsParent.GetChild(i).GetChild(j).GetChild(k).localPosition = PosRotScale.PosRotScalePatchList[temp].PosPatch;
+                            GameManager.Instance.ObjsParent.GetChild(i).GetChild(j).GetChild(k).localEulerAngles = PosRotScale.PosRotScalePatchList[temp].RotPatch;
+                            GameManager.Instance.ObjsParent.GetChild(i).GetChild(j).GetChild(k).localScale = PosRotScale.PosRotScalePatchList[temp].ScalePatch;
+                            temp++;
+                        }
+                    }
+                }
+            }
+        }
+    }
     #endregion
 
     #region 获取景点信息--素材编辑模式下