CheckCanvas.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using XCharts.Runtime;
  5. public class CheckCanvas : MonoBehaviour
  6. {
  7. public LineChart Line;
  8. public LineChart Line2;
  9. // Start is called before the first frame update
  10. void Start()
  11. {
  12. //StartCoroutine("xian1");
  13. //StartCoroutine("xian2");
  14. }
  15. IEnumerator xian1()
  16. {
  17. while (true)
  18. {
  19. yield return new WaitForSeconds(Random.Range(1, 4));
  20. if (Line)
  21. {
  22. SerieData list = Line.series[0].data[0];
  23. Line.series[0].data[0].data[1] = Random.Range(65f, 70f);
  24. Line.series[0].data[1].data[1] = Random.Range(20f, 25f);
  25. Line.series[0].data[2].data[1] = Random.Range(20f, 25f);
  26. Line.series[0].data[3].data[1] = Random.Range(20f, 25f);
  27. Line.series[0].data[4].data[1] = Random.Range(20f, 25f);
  28. // Debug.Log("刷新");
  29. Line.RefreshChart();
  30. }
  31. }
  32. }
  33. IEnumerator xian2()
  34. {
  35. while (true)
  36. {
  37. yield return new WaitForSeconds(Random.Range(1, 4));
  38. if (Line)
  39. {
  40. SerieData list = Line2.series[0].data[0];
  41. Line2.series[0].data[0].data[1] = Random.Range(80f, 85f);
  42. Line2.series[0].data[1].data[1] = Random.Range(80f, 85f);
  43. Line2.series[0].data[2].data[1] = Random.Range(80f, 85f);
  44. Line2.series[0].data[3].data[1] = Random.Range(80f, 85f);
  45. Line2.series[0].data[4].data[1] = Random.Range(80f, 85f);
  46. // Debug.Log("刷新2");
  47. Line2.RefreshChart();
  48. }
  49. }
  50. }
  51. //������ת���Ƕ�����
  52. public int yMinLimit = -20;
  53. public int yMaxLimit = 80;
  54. //��ת�ٶ�
  55. public float xSpeed = 250.0f;//������ת�ٶ�
  56. public float ySpeed = 120.0f;//������ת�ٶ�
  57. //��ת�Ƕ�
  58. private float x = 0.0f;
  59. private float y = 0.0f;
  60. //���ű�������
  61. public float MinScale = 0.2f;
  62. public float MaxScale = 3.0f;
  63. //���ű���
  64. private float scale = 1.0f;
  65. void Update()
  66. {
  67. if (ModelDataManager.Instance.isLoadModel)
  68. {
  69. if (Input.GetMouseButton(0))
  70. {
  71. //Input.GetAxis("MouseX")��ȡ����ƶ���X��ľ���
  72. x += Input.GetAxis("Mouse X") * xSpeed * 0.02f;
  73. y -= Input.GetAxis("Mouse Y") * ySpeed * 0.02f;
  74. y = ClampAngle(y, yMinLimit, yMaxLimit);
  75. //ŷ����ת��Ϊ��Ԫ��
  76. Quaternion rotation = Quaternion.Euler(-y, -x, 0);
  77. transform.rotation = rotation;
  78. }
  79. if (Input.GetAxis("Mouse ScrollWheel") != 0)
  80. {
  81. scale += Input.GetAxis("Mouse ScrollWheel");
  82. scale = Mathf.Clamp(scale, MinScale, MaxScale);
  83. transform.localScale = new Vector3(scale, scale, scale);
  84. }
  85. }
  86. }
  87. //�Ƕȷ�Χֵ�޶�
  88. static float ClampAngle(float angle, float min, float max)
  89. {
  90. if (angle < -360)
  91. angle += 360;
  92. if (angle > 360)
  93. angle -= 360;
  94. return Mathf.Clamp(angle, min, max);
  95. }
  96. }