|
@@ -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);
|
|
|
+
|
|
|
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++)
|
|
|
+ {
|
|
|
+ var spoit = GameManager.Instance.SpoitValues[i-1];
|
|
|
+
|
|
|
+ for (int j = 0; j < spoit.material.Count; j++)
|
|
|
+ {
|
|
|
+ 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);
|
|
|
+ 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);
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ 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);
|
|
|
+
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
@@ -241,6 +347,7 @@ public class UIEditorPanel : MonoBehaviour, EventObserver
|
|
|
|
|
|
public void SelectMaterial(Transform MaterialObj)
|
|
|
{
|
|
|
+ Debug.LogError("MaterialObjName:"+MaterialObj.name);
|
|
|
this.MaterialObj = MaterialObj;
|
|
|
listAlter.Clear();
|
|
|
listAlter = new List<objectData>();
|