SavePanel.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. // GameManager.Instance.
  37. parentObj.SetActive(!b);
  38. }
  39. // private string URL = "https://api-fat3.ghz-tech.com/mr-navigator/v1/project/createposition";
  40. private void Save()
  41. {
  42. meshTest.transform.parent = aRSpaceForAll;
  43. if (posRotlist == null)
  44. {
  45. posRotlist = new List<ScenePosRotInfo>();
  46. posRotlist.Add(pos); posRotlist.Add(rot);
  47. }
  48. /* posRotlist[0].x = meshTest.localPosition.x;
  49. posRotlist[0].y = meshTest.localPosition.y;
  50. posRotlist[0].z = meshTest.localPosition.z;
  51. posRotlist[1].x = meshTest.localEulerAngles.x;
  52. posRotlist[1].y = meshTest.localEulerAngles.y;
  53. posRotlist[1].z = meshTest.localEulerAngles.z;
  54. string jsonString = JsonConvert.SerializeObject(posRotlist);*/
  55. List<Vector2> poslist= GongShi2.GetWebPos(GameManager.Instance.WebMapSize.y, GameManager.Instance.WebMapSize.x, DataManager.Instance.CurrentScene.length, DataManager.Instance.CurrentScene.width);
  56. posRotlist[0].x = poslist[0].x;
  57. posRotlist[0].y = poslist[0].y;
  58. posRotlist[0].z = 0;
  59. posRotlist[1].x = poslist[1].x;
  60. posRotlist[1].y = poslist[1].y;
  61. posRotlist[1].z = 0;
  62. string jsonString = JsonConvert.SerializeObject(posRotlist);
  63. this.SendCommand(new PointPosRotUploadCommand(HttpSDKAction.Instance.loginUrl+ "/project/createPosition", jsonString));
  64. Invoke("setIsOn", 0.1f);
  65. }
  66. void setIsOn()
  67. {
  68. parentToggle.isOn = false;
  69. }
  70. private void Cancle()
  71. {
  72. meshTest.transform.parent = aRSpaceForAll;
  73. // this.gameObject.SetActive(false);
  74. // parentObj.SetActive(true);
  75. Invoke("setIsOn", 0.1f);
  76. }
  77. private void OnEnable()
  78. {
  79. this.SendCommand(new EditorSettingCommand(true){ });
  80. SetSceneActive.Instance.active = true;
  81. goReference.SetActive(true);
  82. }
  83. private void OnDisable()
  84. {
  85. this.SendCommand(new EditorSettingCommand(false){ } );
  86. SetSceneActive.Instance.active = false;
  87. if(goReference!=null)
  88. goReference.SetActive(false);
  89. }
  90. }