using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro; namespace BF { [System.Serializable] public struct GlobalInfo { public TextMeshProUGUI tx; public string key; } [ExecuteInEditMode] [DisallowMultipleComponent] public class GlobalHelper : MonoBehaviour { public List globalInfoList = new List(); public int GetListCount() { return globalInfoList.Count; } public string GetGlobalByIndex(int index) { if (index >= 0 && index < globalInfoList.Count) { return globalInfoList[index].key; } return ""; } public void SetText(int index, string v) { if (index >= 0 && index < globalInfoList.Count) { globalInfoList[index].tx.text = v; } } void OnDestroy() { globalInfoList.Clear(); globalInfoList = null; } } }