using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; namespace BuildSystem { public class UIManager : MonoSingleton { [Header("道路部署阶段")] public GameObject roadPlacePanel; public GameObject tip; [Header("红绿灯放置阶段")] public GameObject placeLight; public GameObject traficWnd; public GameObject lightTip; [Header("通车阶段")] public Button carRun; public GameObject render; public Transform renderGrid; public GameObject rawImagePre; public GameObject carTip; protected override void Awake() { base.Awake(); carRun.onClick.AddListener(()=> { CarController.Instance.StartCreateCar(); carRun.gameObject.SetActive(false); }); } /// /// 道路部署阶段完成的ui更改 /// public void OneStageEnd() { roadPlacePanel.SetActive(false); tip.SetActive(false); placeLight.SetActive(true); traficWnd.SetActive(true); lightTip.SetActive(true); } /// /// 红绿灯部署阶段完成 /// public void TwoStageEnd() { placeLight.SetActive(false); traficWnd.SetActive(false); carRun.gameObject.SetActive(true); render.SetActive(true); carTip.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; } } private void Update() { if (Input.GetKeyDown(KeyCode.Space)) { TwoStageEnd(); } } } }