PointCouldAutoMatchController.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using Blue;
  2. using System;
  3. using UnityEngine;
  4. public class PointCouldAutoMatchController : AbstractController
  5. {
  6. public GameObject AR_Map;
  7. public Vector2 pos1;
  8. public Vector2 pos2;
  9. public double angle;
  10. public Vector3 ScenePos1;
  11. public Vector3 ScenePos2;
  12. private void Awake()
  13. {
  14. this.SubscribeEvent<GetPointPosSuccessEvent>(GetPointPosSuccess);
  15. }
  16. private void GetPointPosSuccess(GetPointPosSuccessEvent e)
  17. {
  18. // 因为屏幕坐标跟普通坐标不同,所依y为-y
  19. angle = this.GetUtility<IGetAngleByTwoPointUtility>().GetAngleByTwoPoint(e.pointJsonInfos[0].x, -e.pointJsonInfos[0].y, e.pointJsonInfos[1].x, -e.pointJsonInfos[1].y);
  20. AR_Map.transform.localEulerAngles = new Vector3(0.0f, (float)angle, 0.0f); //获取角度
  21. pos1 = new Vector2(e.pointJsonInfos[0].x, e.pointJsonInfos[0].y);
  22. pos2 = new Vector2(e.pointJsonInfos[1].x, e.pointJsonInfos[1].y);
  23. this.UnSubscribeEvent<GetPointPosSuccessEvent>(GetPointPosSuccess);
  24. }
  25. public void SetPos(Vector3 pos1, Vector3 pos2)
  26. {
  27. AR_Map.transform.localPosition = pos1;
  28. ScenePos1 = pos1;
  29. ScenePos2 = pos2;
  30. }
  31. }