暫無描述
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Example_PieChart.cs 966B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using UnityEngine;
  2. using XCharts.Runtime;
  3. namespace XCharts.Example
  4. {
  5. [DisallowMultipleComponent]
  6. [ExecuteInEditMode]
  7. [RequireComponent(typeof(PieChart))]
  8. public class Example_PieChart : MonoBehaviour
  9. {
  10. private PieChart chart;
  11. private float time;
  12. private int count = 0;
  13. private void Awake()
  14. {
  15. chart = transform.GetComponent<PieChart>();
  16. chart.ClearData();
  17. }
  18. private void Update()
  19. {
  20. time += Time.deltaTime;
  21. if (time > 1)
  22. {
  23. time = 0;
  24. if (count < 5)
  25. {
  26. chart.AddData(0, Random.Range(10, 100), "time" + count);
  27. }
  28. else
  29. {
  30. int index = count % 5;
  31. chart.UpdateData(0, Random.Range(10, 100), index);
  32. }
  33. count++;
  34. }
  35. }
  36. }
  37. }