using Blue; using Newtonsoft.Json; using SC.XR.Unity; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class SavePanel : AbstractController { public Button saveBtn; public Button cancleBtn; public Transform meshTest; public Transform parent; public SCToggleSwitch3D sCToggleSwitch3D; [SerializeField] private GameObject ARMap; private List posRotlist = new List(); private ScenePosRotInfo pos = new ScenePosRotInfo(); private ScenePosRotInfo rot = new ScenePosRotInfo(); private void Start() { 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(); saveBtn.onClick.AddListener(Save); cancleBtn.onClick.AddListener(Cancle); } private void Save() { meshTest.transform.parent = parent; posRotlist[0].x = meshTest.localPosition.x; posRotlist[0].y = meshTest.localPosition.y; posRotlist[0].z = meshTest.localPosition.z; posRotlist[1].x = meshTest.localEulerAngles.x; posRotlist[1].y = meshTest.localEulerAngles.y; posRotlist[1].z = meshTest.localEulerAngles.z; string jsonString = JsonConvert.SerializeObject(posRotlist); this.SendCommand(new UploadCommand(this.GetService().URL, jsonString)); sCToggleSwitch3D.isOn = false; gameObject.SetActive(false); } private void Cancle() { meshTest.transform.parent = parent; List TempPosRotlist = this.GetService().PosRot; float posX = TempPosRotlist[0].x; float posY = TempPosRotlist[0].y; float posZ = TempPosRotlist[0].z; Vector3 pos = new Vector3(posX, posY, posZ); meshTest.localPosition = pos; float rotX = TempPosRotlist[1].x; float rotY = TempPosRotlist[1].y; float rotZ = TempPosRotlist[1].z; meshTest.localEulerAngles = new Vector3(rotX, rotY, rotZ); sCToggleSwitch3D.isOn = false; gameObject.SetActive(false); } private void OnEnable() { if(ARMap!=null) ARMap.SetActive(false); SetSceneActive.active = true; } private void OnDisable() { if(ARMap!=null) ARMap.SetActive(true); SetSceneActive.active = false; } }