1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- 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<ScenePosRotInfo> posRotlist = new List<ScenePosRotInfo>();
- 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<SCToggleSwitch3D>();
- saveBtn.onClick.AddListener(Save);
- cancleBtn.onClick.AddListener(Cancle);
- }
- private void Save()
- {
- meshTest.transform.parent = parent;
- pos.x = meshTest.localPosition.x;
- pos.y = meshTest.localPosition.y;
- pos.z = meshTest.localPosition.z;
- rot.x = meshTest.localEulerAngles.x;
- rot.y = meshTest.localEulerAngles.y;
- rot.z = meshTest.localEulerAngles.x;
- string jsonString = JsonConvert.SerializeObject(posRotlist);
- this.SendCommand(new UploadCommand(this.GetService<IUpOrDownloadService>().URL, jsonString));
- sCToggleSwitch3D.isOn = false;
- gameObject.SetActive(false);
- }
- private void Cancle()
- {
- meshTest.transform.parent = parent;
- posRotlist = this.GetService<IUpOrDownloadService>().PosRot;
- float posX = posRotlist[0].x;
- float posY = posRotlist[0].y;
- float posZ = posRotlist[0].z;
- Vector3 pos = new Vector3(posX, posY, posZ);
- meshTest.localPosition = pos;
- float rotX = posRotlist[1].x;
- float rotY = posRotlist[1].y;
- float rotZ = posRotlist[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;
- }
- }
|