PointCouldAutoMatchController.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. angle = this.GetUtility<IGetAngleByTwoPointUtility>().GetAngleByTwoPoint(e.pointJsonInfos[0].x, e.pointJsonInfos[0].y, e.pointJsonInfos[1].x, e.pointJsonInfos[1].y);
  19. AR_Map.transform.localEulerAngles = new Vector3(0.0f, (float)angle, 0.0f);
  20. //AR_Map.transform.localPosition = new Vector3(e.pointJsonInfos[0].x, 0, e.pointJsonInfos[0].y);
  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. angle = this.GetUtility<IGetAngleByTwoPointUtility>().GetAngleByTwoPoint(pos1.x,pos1.y,pos2.x,pos2.y);
  28. AR_Map.transform.localEulerAngles = new Vector3(0.0f, (float)angle, 0.0f);
  29. AR_Map.transform.localPosition = pos1;
  30. ScenePos1 = pos1;
  31. ScenePos2 = pos2;
  32. }
  33. }