using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using System; namespace BuildSystem { public class UIManager : MonoSingleton { [Header("道路部署阶段")] public GameObject roadPlacePanel; public GameObject tip; public GameObject level1Target; [Header("红绿灯放置阶段")] public GameObject placeLight; public GameObject traficWnd; public GameObject lightTip; public GameObject level2Target; [Header("通车阶段")] public Button carRun; public GameObject render; public Transform renderGrid; public GameObject rawImagePre; public GameObject carTip; public GameObject carNumber; public Slider carSlider; protected override void Awake() { base.Awake(); carRun.onClick.AddListener(()=> { CarController.Instance.StartCreateCar(); carRun.gameObject.SetActive(false); StartCoroutine(Wait(()=> { EduCoderTool.WebConnecter.Singleton.SendResultToWeb(true); },30f)); }); carSlider.onValueChanged.AddListener(CarController.Instance.CarNumberChange); } /// /// 道路部署阶段完成的ui更改 /// public void OneStageEnd() { roadPlacePanel.SetActive(false); tip.SetActive(false); level1Target.SetActive(false); placeLight.SetActive(true); traficWnd.SetActive(true); level2Target.SetActive(true); lightTip.SetActive(true); } /// /// 红绿灯部署阶段完成 /// public void TwoStageEnd() { level2Target.SetActive(false); carRun.gameObject.SetActive(true); render.SetActive(true); carTip.SetActive(true); carNumber.SetActive(true); foreach (GridInfo info in BuildSystemManager.Instance.grid) { GameObject obj = Instantiate(rawImagePre,renderGrid); RenderTexture renderTexture = new RenderTexture(300,200,0); obj.GetComponent().texture = renderTexture; info.placeObject.GetComponent().camera.gameObject.SetActive(true); info.placeObject.GetComponent().camera.targetTexture = renderTexture; obj.GetComponent().renderGrid = renderGrid; } } IEnumerator Wait(Action action, float t) { yield return new WaitForSeconds(t); action(); } } }