DebugForDevice.cs 1017 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. public class DebugForDevice : MonoBehaviour
  7. {
  8. public static DebugForDevice ins;
  9. void Awake()
  10. {
  11. if (ins) {
  12. Destroy(this.gameObject);
  13. } else {
  14. ins = this;
  15. DontDestroyOnLoad(this.gameObject);
  16. }
  17. }
  18. int tid = 0;
  19. string[] logs = new string[3];
  20. public void LogInfrared(string info) {
  21. tid++;
  22. string text = $"第{tid}波信息\n{info}\n\n";
  23. if (tid <= logs.Length) {
  24. logs[tid - 1] = text;
  25. } else {
  26. for (int i = 0; i < logs.Length - 1; i++) {
  27. logs[i] = logs[i + 1];
  28. }
  29. logs[logs.Length - 1] = text;
  30. }
  31. string logInfo = "";
  32. for (int i = 0; i < tid && i < logs.Length; i++) {
  33. logInfo += logs[i];
  34. }
  35. this.transform.Find("T").GetComponentInChildren<Text>().text = logInfo;
  36. }
  37. }