using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class DebugDeviceCMD : MonoBehaviour { public static DebugDeviceCMD ins; Transform textGroup; string[] textStrList; int index = 0; void Awake() { if (ins) { Destroy(this.gameObject); return; } ins = this; DontDestroyOnLoad(this.gameObject); textGroup = transform.Find("TextGroup"); textStrList = new string[textGroup.childCount]; for (int i = 0; i < textStrList.Length; i++) { textStrList[i] = ""; } } public void ShowCMD(string cmd) { string str = $"序号{index}: {cmd}"; index++; if (index < textStrList.Length) { textStrList[index] = str; } else { System.Array.Copy(textStrList, 1, textStrList, 0, textStrList.Length - 1); textStrList[textStrList.Length - 1] = str; } for (int i = 0; i < textStrList.Length; i++) { textGroup.GetChild(i).GetComponent().text = textStrList[i]; } } // float t = 0; // void Update() { // t += Time.deltaTime; // if (t > 0.1f) { // t = 0; // ShowCMD("A" + index); // } // } }