using Blue; using Newtonsoft.Json; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class SavePanel : AbstractController { public GameObject txtTip; public Button saveBtn; public Button cancleBtn; public Transform meshTest => (SceneIOCContainer.Instance.Pull("mesh_test") as GameObject).transform; public Transform aRSpaceForAll=>(SceneIOCContainer.Instance.Pull("ARSpaceForAll")as GameObject).transform; public GameObject parentObj; public Toggle parentToggle; private List posRotlist ; private ScenePosRotInfo pos = new ScenePosRotInfo(); private ScenePosRotInfo rot = new ScenePosRotInfo(); public LoadReference LoadReferenceController; private GameObject goReference // 参照物 { get =>SceneIOCContainer.Instance.Pull("goRefrence")as GameObject; } private void Start() { saveBtn.onClick.AddListener(Save); cancleBtn.onClick.AddListener(Cancle); } public void setOpen(bool b) { if (b) { txtTip.SetActive(true); txtTip.GetComponentInChildren().text = "如需移动场景,请按住手柄拖动场景并走动\n场景将跟随您的脚步进行整体移动"; } this.gameObject.SetActive(b); // GameManager.Instance. parentObj.SetActive(!b); } // private string URL = "https://api-fat3.ghz-tech.com/mr-navigator/v1/project/createposition"; private void Save() { meshTest.transform.parent = aRSpaceForAll; if (posRotlist == null) { posRotlist = new List(); posRotlist.Add(pos); posRotlist.Add(rot); } /* 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);*/ List poslist= GongShi2.GetWebPos(GameManager.Instance.WebMapSize.y, GameManager.Instance.WebMapSize.x, DataManager.Instance.CurrentScene.length, DataManager.Instance.CurrentScene.width); posRotlist[0].x = poslist[0].x; posRotlist[0].y = poslist[0].y; posRotlist[0].z = 0; posRotlist[1].x = poslist[1].x; posRotlist[1].y = poslist[1].y; posRotlist[1].z = 0; string jsonString = JsonConvert.SerializeObject(posRotlist); this.SendCommand(new PointPosRotUploadCommand(HttpSDKAction.Instance.loginUrl+ "/project/createPosition", jsonString)); Invoke("setIsOn", 0.1f); } void setIsOn() { parentToggle.isOn = false; } private void Cancle() { meshTest.transform.parent = aRSpaceForAll; // this.gameObject.SetActive(false); // parentObj.SetActive(true); Invoke("setIsOn", 0.1f); } private void OnEnable() { this.SendCommand(new EditorSettingCommand(true){ }); SetSceneActive.Instance.active = true; goReference.SetActive(true); } private void OnDisable() { this.SendCommand(new EditorSettingCommand(false){ } ); SetSceneActive.Instance.active = false; if(goReference!=null) goReference.SetActive(false); } }