You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
2.2 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace BuildSystem
{
public class UIManager : MonoSingleton<UIManager>
{
[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);
});
}
/// <summary>
/// 道路部署阶段完成的ui更改
/// </summary>
public void OneStageEnd() {
roadPlacePanel.SetActive(false);
tip.SetActive(false);
placeLight.SetActive(true);
traficWnd.SetActive(true);
lightTip.SetActive(true);
}
/// <summary>
/// 红绿灯部署阶段完成
/// </summary>
public void TwoStageEnd() {
placeLight.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<RawImage>().texture = renderTexture;
info.placeObject.GetComponent<RoadInfo>().camera.gameObject.SetActive(true);
info.placeObject.GetComponent<RoadInfo>().camera.targetTexture = renderTexture;
obj.GetComponent<RenderRawImg>().renderGrid = renderGrid;
}
}
private void Update()
{
if (Input.GetKeyDown(KeyCode.Space)) {
TwoStageEnd();
}
}
}
}