using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class DebugForDevice : MonoBehaviour { public static DebugForDevice ins; void Awake() { if (ins) { Destroy(this.gameObject); } else { ins = this; DontDestroyOnLoad(this.gameObject); } } int tid = 0; string[] logs = new string[3]; public void LogInfrared(string info) { tid++; string text = $"第{tid}波信息\n{info}\n\n"; if (tid <= logs.Length) { logs[tid - 1] = text; } else { for (int i = 0; i < logs.Length - 1; i++) { logs[i] = logs[i + 1]; } logs[logs.Length - 1] = text; } string logInfo = ""; for (int i = 0; i < tid && i < logs.Length; i++) { logInfo += logs[i]; } this.transform.Find("T").GetComponentInChildren().text = logInfo; } }