LinePath.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Net;
  4. using Unity.Mathematics;
  5. using Unity.VisualScripting;
  6. using UnityEngine;
  7. using UnityEngine.EventSystems;
  8. using XCharts.Runtime;
  9. public enum LineDir
  10. {
  11. Out,
  12. In
  13. };
  14. public enum ZYTime
  15. {
  16. Before,
  17. After,
  18. };
  19. public class LinePath : MonoBehaviour
  20. {
  21. public LineDir lineDir;
  22. public string startPos;
  23. public string endPos;
  24. public string linePathContent;
  25. public int manNum;
  26. public int homeNum;
  27. public int completeNum;
  28. public string dateTime;
  29. public GameObject lineRenderer;
  30. public Material firMat;
  31. public Material secMat;
  32. void Start()
  33. {
  34. }
  35. //public void SetPath(Vector3 start, Vector3 end) {
  36. // this.transform.position = start;
  37. // Vector3 direction = end - start;
  38. // Vector3 up = Vector3.up; // (0,1,0)
  39. // // 计算夹角
  40. // float angle = Vector3.Angle(direction, up);
  41. // // 使用叉积来判断方向
  42. // Vector3 crossProduct = Vector3.Cross(direction, up);
  43. // if (crossProduct.z < 0)
  44. // {
  45. // angle = 360 - angle;
  46. // }
  47. // //print(angle);
  48. // float distance = Vector3.Distance(end, start);
  49. // this.transform.localScale = new Vector3(1,distance / 2,1);
  50. // this.transform.eulerAngles = new Vector3(1, 1, -angle);
  51. //}
  52. public void OnShow()
  53. {
  54. if (RKZYLayer.lineInfoStatic)
  55. {
  56. if (!RKZYLayer.lineInfoStatic.linePaths.Contains(this))
  57. {
  58. RKZYLayer.lineInfoStatic.SetData(this);
  59. RKZYLayer.lineInfoStatic.GetComponent<RectTransform>().anchoredPosition = Input.mousePosition * 1920 / Screen.width;
  60. RKZYLayer.lineInfoStatic.linePaths.Add(this);
  61. //this.lineRenderer.GetComponent<MeshRenderer>().material = secMat;
  62. }
  63. }
  64. }
  65. public void UnShow()
  66. {
  67. RKZYLayer.lineInfoStatic.linePaths.Remove(this);
  68. //this.lineRenderer.GetComponent<MeshRenderer>().material = firMat;
  69. }
  70. //private void Update()
  71. //{
  72. // if (CameraManager.instance.secondCamera != null) {
  73. // float dyScale = CameraManager.instance.secondCamera.GetComponent<CameraBirdSec>().currentDistance / 6;
  74. // dyScale = math.clamp(dyScale, 1, 12);
  75. // this.transform.localScale = new Vector3(dyScale, this.transform.localScale.y, dyScale);
  76. // this.lineRenderer.GetComponent<MeshRenderer>().material.SetTextureScale("_MainTex", new Vector2(1, this.transform.localScale.y * 10 / this.transform.localScale.x));
  77. // }
  78. //}
  79. }