LinePath.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. public float xishu;
  33. void Start()
  34. {
  35. }
  36. //public void SetPath(Vector3 start, Vector3 end) {
  37. // this.transform.position = start;
  38. // Vector3 direction = end - start;
  39. // Vector3 up = Vector3.up; // (0,1,0)
  40. // // 计算夹角
  41. // float angle = Vector3.Angle(direction, up);
  42. // // 使用叉积来判断方向
  43. // Vector3 crossProduct = Vector3.Cross(direction, up);
  44. // if (crossProduct.z < 0)
  45. // {
  46. // angle = 360 - angle;
  47. // }
  48. // //print(angle);
  49. // float distance = Vector3.Distance(end, start);
  50. // this.transform.localScale = new Vector3(1,distance / 2,1);
  51. // this.transform.eulerAngles = new Vector3(1, 1, -angle);
  52. //}
  53. public void OnShow()
  54. {
  55. if (RKZYLayer.lineInfoStatic)
  56. {
  57. if (!RKZYLayer.lineInfoStatic.linePaths.Contains(this))
  58. {
  59. RKZYLayer.lineInfoStatic.SetData(this);
  60. RKZYLayer.lineInfoStatic.GetComponent<RectTransform>().anchoredPosition = Input.mousePosition * 1920 / Screen.width;
  61. RKZYLayer.lineInfoStatic.linePaths.Add(this);
  62. //this.lineRenderer.GetComponent<MeshRenderer>().material = secMat;
  63. }
  64. }
  65. }
  66. public void UnShow()
  67. {
  68. RKZYLayer.lineInfoStatic.linePaths.Remove(this);
  69. //this.lineRenderer.GetComponent<MeshRenderer>().material = firMat;
  70. }
  71. //private void Update()
  72. //{
  73. // if (CameraManager.instance.secondCamera != null) {
  74. // float dyScale = CameraManager.instance.secondCamera.GetComponent<CameraBirdSec>().currentDistance / 6;
  75. // dyScale = math.clamp(dyScale, 1, 12);
  76. // this.transform.localScale = new Vector3(dyScale, this.transform.localScale.y, dyScale);
  77. // this.lineRenderer.GetComponent<MeshRenderer>().material.SetTextureScale("_MainTex", new Vector2(1, this.transform.localScale.y * 10 / this.transform.localScale.x));
  78. // }
  79. //}
  80. }