OperaComponent.cs 858 B

12345678910111213141516171819202122232425262728293031
  1. using UnityEngine;
  2. namespace Model
  3. {
  4. [ObjectEvent]
  5. public class OperaComponentEvent : ObjectEvent<OperaComponent>, IUpdate
  6. {
  7. public void Update()
  8. {
  9. this.Get().Update();
  10. }
  11. }
  12. public class OperaComponent: Component
  13. {
  14. public Vector3 ClickPoint;
  15. public void Update()
  16. {
  17. if (Input.GetMouseButtonUp(0))
  18. {
  19. Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
  20. RaycastHit hit;
  21. Physics.Raycast(ray, out hit, 1000);
  22. this.ClickPoint = hit.point;
  23. Log.Debug($"click {this.ClickPoint}");
  24. SessionComponent.Instance.Session.Send(new Frame_ClickMap() {X = (int)(this.ClickPoint.x * 1000), Z = (int)(this.ClickPoint.z * 1000)});
  25. }
  26. }
  27. }
  28. }