Browse Source

Merge branch 'master' into F/0710_2.1+2.0

# Conflicts:
#	Assets/MRNavigatorPro.unity
#	Assets/Scripts/UI/GameManager.cs
胡佳骏 1 year ago
parent
commit
4964a52f68

+ 16 - 0
Assets/Resources/Template/Prefab/Image.prefab

@@ -13,6 +13,7 @@ GameObject:
   - component: {fileID: 7223857886156994697}
   - component: {fileID: 415156925351255577}
   - component: {fileID: 8376925436645686227}
+  - component: {fileID: 7706840194356506355}
   m_Layer: 0
   m_Name: Image
   m_TagString: Untagged
@@ -154,6 +155,21 @@ MonoBehaviour:
   canTwoHandScale: 0
   minScaleRatio: 0.5
   maxScaleRatio: 3
+--- !u!114 &7706840194356506355
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 227738178650662433}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: f2c924915f6be274b8af2986784ee2c1, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  boundingBox: {fileID: 7223857886156994697}
+  manipulationHandler: {fileID: 8376925436645686227}
+  obj_BoundingBox: {fileID: 0}
 --- !u!1 &5709561373420343274
 GameObject:
   m_ObjectHideFlags: 0

+ 9 - 0
Assets/Scripts/BaseManager/DataManager.cs

@@ -164,6 +164,15 @@ public class DataManager : SingletonMono<DataManager>
         JObject jObject = JObject.Parse(message);
         string str = jObject["message"].ToString();
 
+        if(str!="更新成功")
+        {
+            InstantiateCommand Command =new InstantiateCommand(
+                InstantiateSystem.Instance.BlueObject.WarningPopUp,
+                InstantiateSystem.Instance.BlueObject.NetErrorText);
+            CommandSystem.Instance.Send(Command);
+            return;
+        }
+
         UIManager.Instance.ShowUI(UINameConfig.LoadingPanel, typeof(LoadingPanel), (int)ELoadState.SaveSpoitDataEnd);
         ((LoadingPanel)UIManager.Instance.GetUI(UINameConfig.LoadingPanel)).TextStr = str;
     }

+ 54 - 0
Assets/Scripts/Blue/Patch/Patch_ModelController.cs

@@ -0,0 +1,54 @@
+using SC.XR.Unity.Module_InputSystem;
+using UnityEngine;
+using UnityEngine.UI;
+using static BoundingBox;
+
+public class Patch_ModelController : AbstractController
+{
+    [SerializeField] private BoundingBox boundingBox;
+    [SerializeField] private ManipulationHandler manipulationHandler;
+    void Start()
+    {
+        if (GetComponent<ManipulationHandler>() != null)
+        {
+            Destroy(manipulationHandler);
+        }
+
+        if (GetComponent<BoundingBox>() != null)
+        {
+            Destroy(boundingBox);
+        }
+
+        toggle = GameObject.Find("SetBtn/Canvas/Parent/EditorBtn/Toggle").GetComponent<Toggle>();
+    }
+
+    private Toggle toggle;
+
+    private void Update()
+    {
+        if(!toggle.isOn)
+        {
+            if(manipulationHandler!=null)
+                Destroy(manipulationHandler);
+            if (boundingBox != null)
+            {
+                Destroy(boundingBox);
+                if (transform.Find("BoundingBox").gameObject != null)
+                    Destroy(transform.Find("BoundingBox").gameObject);
+            }
+        }
+        else
+        {
+            if (manipulationHandler == null)
+            {
+                manipulationHandler = gameObject.AddComponent<ManipulationHandler>();
+            }
+            if (boundingBox == null)
+            {
+                boundingBox = gameObject.AddComponent<BoundingBox>();
+                boundingBox.FlattenAxis = FlattenModeType.DoNotFlatten;
+                boundingBox.ActiveHandle = HandleType.Rotation | HandleType.Scale;
+            }
+        }
+    }
+}

+ 11 - 0
Assets/Scripts/Blue/Patch/Patch_ModelController.cs.meta

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

+ 13 - 0
Assets/Scripts/Blue/Patch/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/Patch/PosRotScale.cs.meta

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

+ 38 - 29
Assets/Scripts/Blue/Patch/Video/Patch_VideoController.cs

@@ -1,45 +1,54 @@
-using System.Collections;
-using System.Collections.Generic;
-using Blue;
 using SC.XR.Unity.Module_InputSystem;
 using UnityEngine;
+using UnityEngine.UI;
+using static BoundingBox;
 
 public class Patch_VideoController : AbstractController
 {
     [SerializeField] private BoundingBox boundingBox;
     [SerializeField] private ManipulationHandler manipulationHandler;
-    [SerializeField] private GameObject obj_BoundingBox;
+
     void Start()
     {
-        this.RegisterEvent<Patch_VideoEvent>(e=>
+        if (GetComponent<ManipulationHandler>() != null)
+        {
+            Destroy(manipulationHandler);
+        }
+
+        if (GetComponent<BoundingBox>() != null)
+        {
+            Destroy(boundingBox);
+        }
+
+        toggle = GameObject.Find("SetBtn/Canvas/Parent/EditorBtn/Toggle").GetComponent<Toggle>();
+    }
+
+    private Toggle toggle;
+    private void Update()
+    {
+        if(!toggle.isOn)
         {
-            if(e.set)
+            if(manipulationHandler!=null)
+                Destroy(manipulationHandler);
+            if (boundingBox != null)
             {
-                if(obj_BoundingBox!=null)
-                {
-                    obj_BoundingBox.SetActive(true);
-                    manipulationHandler.enabled = true;
-                }
-                else
-                {
-                    boundingBox.enabled = true;
-                    manipulationHandler.enabled = true;
-                    StartCoroutine(GetBoundingBox());
-                }
+                Destroy(boundingBox);
+                if (transform.Find("BoundingBox").gameObject != null)
+                    Destroy(transform.Find("BoundingBox").gameObject);
             }
-            else
+        }
+        else
+        {
+            if (manipulationHandler == null)
             {
-                obj_BoundingBox.SetActive(false);
-                boundingBox.enabled = false;
-                manipulationHandler.enabled = false;
+                manipulationHandler = gameObject.AddComponent<ManipulationHandler>();
             }
-        });
-    }
-
-    private IEnumerator GetBoundingBox()
-    {
-        yield return null;
-        if(transform.Find("BoundingBox").gameObject!=null)
-            obj_BoundingBox = transform.Find("BoundingBox").gameObject;
+            if (boundingBox == null)
+            {
+                boundingBox = gameObject.AddComponent<BoundingBox>();
+                boundingBox.FlattenAxis = FlattenModeType.FlattenZ;
+                boundingBox.ActiveHandle = HandleType.Rotation | HandleType.Scale;
+            }
+        }
     }
 }

+ 1 - 0
Assets/Scripts/LayoutTemplate/TemplateModel.cs

@@ -85,6 +85,7 @@ public class TemplateModel : BaseTemPlate
 
                 gameObject.AddComponent<ManipulationHandler>();
                 gameObject.AddComponent<BoundingBox>();
+                gameObject.AddComponent<Patch_ModelController>();
                 yield return new WaitForSeconds(0.3f);
                 ab.assetBundle.Unload(false);
                 HideCollider();

+ 9 - 0
Assets/Scripts/UI/AnchorEditorPanel/UIAnchorsPanel.cs

@@ -90,6 +90,15 @@ public class UIAnchorsPanel : UIPanelBase
         JObject jObject = JObject.Parse(message);
         string str = jObject["message"].ToString();
 
+        if(str!="更新成功")
+        {
+            InstantiateCommand Command =new InstantiateCommand(
+                InstantiateSystem.Instance.BlueObject.WarningPopUp,
+                InstantiateSystem.Instance.BlueObject.NetErrorText);
+            CommandSystem.Instance.Send(Command);
+            return;
+        }
+
         UIManager.Instance.ShowUI(UINameConfig.LoadingPanel, typeof(LoadingPanel), (int)ELoadState.SaveSpoitDataEnd);
         ((LoadingPanel)UIManager.Instance.GetUI(UINameConfig.LoadingPanel)).TextStr = str;
     }

+ 110 - 3
Assets/Scripts/UI/EdirPanel/UIEditorPanel.cs

@@ -1,10 +1,13 @@
 using System;
 using System.Collections;
 using System.Collections.Generic;
+using Blue;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
 using UnityEngine;
+using UnityEngine.Assertions.Must;
 using UnityEngine.UI;
-
-public class UIEditorPanel : MonoBehaviour, EventObserver
+public class UIEditorPanel : AbstractController, EventObserver
 {
 
     public event Action<GameObject> OnClickRemoveBtn;
@@ -227,13 +230,116 @@ public class UIEditorPanel : MonoBehaviour, EventObserver
 
         SaveBtn.onClick.AddListener(() =>
         {
+            /*
             if (MaterialObj == null)
+            {
+                InstantiateCommand Command = new InstantiateCommand(
+                InstantiateSystem.Instance.BlueObject.WarningPopUp,
+                "保存失败\n服务器异常,请稍后重试");
+                CommandSystem.Instance.Send(Command);
+                //this.GetService<ISendLogService>().SendLog("Blue","请选择素材");
                 return;
+            }
             GameManager.Instance.SaveSpoitObjs();
-
+            */
+            StartCoroutine(SetSpoitInfo());
         });
     }
 
+    public IEnumerator SetSpoitInfo()
+    {
+        countSplit =0;saveData.Clear();
+        int count = GameManager.Instance.ObjsParent.childCount;
+        for (int i = 1; i <= count-1;i++) // 第一个LocalNULLShowObj是无用的
+        {
+            var spoit = GameManager.Instance.SpoitValues[i-1]; // 某个景点
+
+            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-1); //// 第一个LocalNULLShowObj是无用的 ,so -1
+            yield return null;
+        }
+    }
+    private List<SendSaveData> saveData = new List<SendSaveData>();
+    private void SplitSpoitData(SpoitValue spoit,int spoitCount)
+    {
+        countSplit++;
+        SendSaveData data = new SendSaveData();
+        data.id = spoit.id;
+        data.name = spoit.name;
+        data.projectId = DataManager.Instance.ProjectID;
+        data.material = spoit.material;
+        data.spoittf = spoit.spoitTf;
+        saveData.Add(data);
+
+        string sendData = JsonConvert.SerializeObject(saveData);
+        Debug.LogError(countSplit+"=="+spoitCount);
+        if(countSplit==spoitCount)
+            HttpTool.Instance.PostTest("/viewpoint/update", sendData, SaveCallBack);
+    }
+    private int countSplit =0;
+
+    private void SaveCallBack(string message)
+    {
+        if (message == "UnityWebRequest Error")
+        {
+            InstantiateCommand ErrorCommand = new InstantiateCommand(
+                InstantiateSystem.Instance.BlueObject.WarningPopUp,
+                InstantiateSystem.Instance.BlueObject.NetErrorText);
+            CommandSystem.Instance.Send(ErrorCommand);
+            //this.GetService<ISendLogService>().SendLog("Blue","UnityWebRequest Error");
+            return;
+        }
+
+        //Debug.LogError("SaveCallBack:  " + message);
+        JObject jObject = JObject.Parse(message);
+        string str = jObject["message"].ToString();
+        if (str != "更新成功")
+        {
+            InstantiateCommand ErrorCommand = new InstantiateCommand(
+                InstantiateSystem.Instance.BlueObject.WarningPopUp,
+                InstantiateSystem.Instance.BlueObject.NetErrorText);
+            CommandSystem.Instance.Send(ErrorCommand);
+            Debug.LogError("执行协程数:" + countSplit);
+            //this.GetService<ISendLogService>().SendLog("Blue","更新成功出现问题");
+            return;
+        }
+        Debug.Log("更新成功");
+        UIManager.Instance.ShowUI(UINameConfig.LoadingPanel, typeof(LoadingPanel), (int)ELoadState.SaveSpoitDataEnd);
+        ((LoadingPanel)UIManager.Instance.GetUI(UINameConfig.LoadingPanel)).TextStr = str;
+
+        InstantiateCommand Command = new InstantiateCommand(
+                InstantiateSystem.Instance.BlueObject.WarningPopUp,
+                InstantiateSystem.Instance.BlueObject.SuccessText);
+        CommandSystem.Instance.Send(Command);
+
+        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);
+                    }
+                }
+            }
+        }
+    }
 
     /// <summary>
     ///  选择素材
@@ -241,6 +347,7 @@ public class UIEditorPanel : MonoBehaviour, EventObserver
     /// <param name="MaterialObj"></param>
     public void SelectMaterial(Transform MaterialObj)
     {
+        Debug.LogError("MaterialObjName:"+MaterialObj.name);
         this.MaterialObj = MaterialObj;
         listAlter.Clear();
         listAlter = new List<objectData>();

+ 28 - 1
Assets/Scripts/UI/GameManager.cs

@@ -209,6 +209,7 @@ public class GameManager : MonoSingleton<GameManager>
         set { m_AnchorChild = value; }
     }
 
+    public Toggle EditorToggle;
     private void Awake()
     {
         
@@ -403,7 +404,6 @@ public class GameManager : MonoSingleton<GameManager>
         InitCrystals();
         InitBoxColliders();
 
-       
 
     }
 
@@ -1620,9 +1620,36 @@ public class GameManager : MonoSingleton<GameManager>
                 SpoitIndex = i;
                 ListCrystals[SpoitIndex].gameObject.SetActive(false);
                 m_EditorPanel.SetSpoit(SpoitValues[i]);
+                StartCoroutine(patch());
                 return;
             }
         }
+        StartCoroutine(patch());
+    }
+
+    private IEnumerator patch()
+    {
+        yield return new WaitForSeconds(0.005f);
+        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++;
+                        }
+                    }
+                }
+            }
+        }
     }
     /// <summary>
     /// 当人物退出触发器范围