using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public enum CarType { 首页, 车类型, 天气, 危险驾驶 } public class GameManager : MonoBehaviour { public static GameManager instance; // public List home; //首页 // // // public List carType; //车类型 // public List weather; //天气 // public List dangerDriving; //危险驾驶 public GameObject[] uiGames; public Button[] btList = new Button[] { }; private List stepValues = new List(); // 保存每个步骤的值 private int currentStep = 0; // 当前步骤索引 private CarType carType; private void Awake() { instance = this; // home = new List(); // // carType = new List(); // weather = new List(); // dangerDriving = new List(); DontDestroyOnLoad(this); } private void Start() { // // 等待所有 BtClick 对象的 Start 方法完成 // yield return StartCoroutine(WaitForBtClickStarts()); // // // 所有 BtClick 的 Start 方法已完成,继续执行其他代码 // Debug.Log("All BtClick Start methods completed."); // // 执行其他方法 // for (int i = 0; i < uiGames.Length; i++) // { // uiGames[i].SetActive(false); // } // // uiGames[0].SetActive(true); // GetComponent().buttons = home; UIClick(CarType.首页, ""); } // private IEnumerator WaitForBtClickStarts() // { // // 获取所有 BtClick 实例 // BtClick[] btClicks = FindObjectsOfType(); // int completedCount = 0; // // // 为每个 BtClick 实例的 OnStartCompleted 事件添加监听器 // foreach (var btClick in btClicks) // { // btClick.OnStartCompleted += () => { completedCount++; }; // } // // // 等待直到所有 BtClick 实例的 Start 方法完成 // while (completedCount < btClicks.Length) // { // yield return null; // 等待一帧 // } // } public void SceneBts() { Button[] buttonArray = new Button[] { }; switch (carType) { case CarType.首页: buttonArray = uiGames[0].GetComponentsInChildren