SavePanel.cs 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. using Blue;
  2. using Newtonsoft.Json;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. public class SavePanel : AbstractController
  7. {
  8. public GameObject txtTip;
  9. public Button saveBtn;
  10. public Button cancleBtn;
  11. public Transform meshTest => (SceneIOCContainer.Instance.Pull("mesh_test") as GameObject).transform;
  12. public Transform aRSpaceForAll=>(SceneIOCContainer.Instance.Pull("ARSpaceForAll")as GameObject).transform;
  13. public GameObject parentObj;
  14. public Toggle parentToggle;
  15. private List<ScenePosRotInfo> posRotlist ;
  16. private ScenePosRotInfo pos = new ScenePosRotInfo();
  17. private ScenePosRotInfo rot = new ScenePosRotInfo();
  18. public LoadReference LoadReferenceController;
  19. private GameObject goReference // 参照物
  20. {
  21. get =>SceneIOCContainer.Instance.Pull("goRefrence")as GameObject;
  22. }
  23. private void Start()
  24. {
  25. saveBtn.onClick.AddListener(Save);
  26. cancleBtn.onClick.AddListener(Cancle);
  27. }
  28. public void setOpen(bool b)
  29. {
  30. if (b)
  31. {
  32. txtTip.SetActive(true);
  33. txtTip.GetComponentInChildren<Text>().text = "如需移动场景,请按住手柄拖动场景并走动\n场景将跟随您的脚步进行整体移动";
  34. }
  35. this.gameObject.SetActive(b);
  36. parentObj.SetActive(!b);
  37. }
  38. // private string URL = "https://api-fat3.ghz-tech.com/mr-navigator/v1/project/createposition";
  39. private void Save()
  40. {
  41. meshTest.transform.parent = aRSpaceForAll;
  42. if (posRotlist == null)
  43. {
  44. posRotlist = new List<ScenePosRotInfo>();
  45. posRotlist.Add(pos); posRotlist.Add(rot);
  46. }
  47. /* posRotlist[0].x = meshTest.localPosition.x;
  48. posRotlist[0].y = meshTest.localPosition.y;
  49. posRotlist[0].z = meshTest.localPosition.z;
  50. posRotlist[1].x = meshTest.localEulerAngles.x;
  51. posRotlist[1].y = meshTest.localEulerAngles.y;
  52. posRotlist[1].z = meshTest.localEulerAngles.z;
  53. string jsonString = JsonConvert.SerializeObject(posRotlist);*/
  54. List<Vector2> poslist= GongShi2.GetWebPos(GameManager.Instance.WebMapSize.y, GameManager.Instance.WebMapSize.x, DataManager.Instance.CurrentScene.length, DataManager.Instance.CurrentScene.width);
  55. posRotlist[0].x = poslist[0].x;
  56. posRotlist[0].y = poslist[0].y;
  57. posRotlist[0].z = 0;
  58. posRotlist[1].x = poslist[1].x;
  59. posRotlist[1].y = poslist[1].y;
  60. posRotlist[1].z = 0;
  61. string jsonString = JsonConvert.SerializeObject(posRotlist);
  62. this.SendCommand(new PointPosRotUploadCommand(HttpSDKAction.Instance.loginUrl+ "/project/createPosition", jsonString));
  63. }
  64. void setIsOn()
  65. {
  66. parentToggle.isOn = false;
  67. }
  68. private void Cancle()
  69. {
  70. meshTest.transform.parent = aRSpaceForAll;
  71. this.gameObject.SetActive(false);
  72. parentObj.SetActive(true);
  73. Invoke("setIsOn", 0.1f);
  74. }
  75. private void OnEnable()
  76. {
  77. this.SendCommand(new EditorSettingCommand(true){ });
  78. SetSceneActive.Instance.active = true;
  79. goReference.SetActive(true);
  80. }
  81. private void OnDisable()
  82. {
  83. this.SendCommand(new EditorSettingCommand(false){ } );
  84. SetSceneActive.Instance.active = false;
  85. if(goReference!=null)
  86. goReference.SetActive(false);
  87. }
  88. }