using System.Collections; using System.Collections.Generic; using Kill.Managers; using UnityEngine; using UnityEngine.UI; using System; namespace Kill.UI.Pages { public class HomePageCtrl : MonoBehaviour { public GameObject noDevicePage; // 存储待执行的UI更新操作 private List pendingUIUpdates = new List(); void Start() { Init(); } void Update() { // 执行所有挂起的UI更新 if (pendingUIUpdates.Count > 0) { foreach (var update in pendingUIUpdates) { update?.Invoke(); } pendingUIUpdates.Clear(); } } public void Init() { if(DataManager.Instance.userInfo.device_count==0) { noDevicePage.SetActive(true); } else { noDevicePage.SetActive(false); } } public void ConnectDevice() { if(!CheckSafetylearning()) { UIManager.Instance.OpenPage(UIManager.PageName.safetylearningPage); return; } UIManager.Instance.OpenPage(UIManager.PageName.connectDevicePage); } public bool CheckSafetylearning() { bool isPassed=false; isPassed=DataManager.Instance.userInfo.exam_completed; return isPassed; } } }