tuijiao
This commit is contained in:
parent
585c819adf
commit
234b98c440
File diff suppressed because it is too large
Load Diff
|
@ -4,12 +4,14 @@ using System.Collections.Generic;
|
|||
using System.Threading.Tasks;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public enum TrafficLightState
|
||||
{
|
||||
Red,
|
||||
Yellow,
|
||||
Green
|
||||
}
|
||||
|
||||
public class TrafficLightManager : MonoBehaviour
|
||||
{
|
||||
[System.Serializable]
|
||||
|
@ -33,11 +35,10 @@ public class TrafficLightManager : MonoBehaviour
|
|||
|
||||
public void UpdateTrafficLightTexture(TrafficLightState state)
|
||||
{
|
||||
Debug.Log("123");
|
||||
|
||||
Debug.Log("123");
|
||||
|
||||
foreach (var light in trafficLights)
|
||||
{
|
||||
foreach (var light in trafficLights)
|
||||
{
|
||||
if (light != null)
|
||||
{
|
||||
// 假设你有一个方法来根据状态获取相应的贴图
|
||||
|
@ -46,7 +47,7 @@ foreach (var light in trafficLights)
|
|||
light.transform.Find("yellow1").GetComponent<MeshRenderer>().material.DisableKeyword("_EMISSION");
|
||||
light.transform.Find("green2").GetComponent<MeshRenderer>().material.DisableKeyword("_EMISSION");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (state)
|
||||
{
|
||||
|
@ -60,6 +61,7 @@ foreach (var light in trafficLights)
|
|||
light.transform.Find("red2").GetComponent<MeshRenderer>().material.EnableKeyword("_EMISSION");
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case TrafficLightState.Yellow:
|
||||
foreach (var light in trafficLights)
|
||||
|
@ -71,6 +73,7 @@ foreach (var light in trafficLights)
|
|||
light.transform.Find("yellow1").GetComponent<MeshRenderer>().material.EnableKeyword("_EMISSION");
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case TrafficLightState.Green:
|
||||
foreach (var light in trafficLights)
|
||||
|
@ -82,11 +85,11 @@ foreach (var light in trafficLights)
|
|||
light.transform.Find("green2").GetComponent<MeshRenderer>().material.EnableKeyword("_EMISSION");
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(state), state, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// private Texture GetTextureForState(TrafficLightState state)
|
||||
|
@ -105,7 +108,6 @@ foreach (var light in trafficLights)
|
|||
{
|
||||
group.Initialize();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -157,9 +159,6 @@ foreach (var light in trafficLights)
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void UpdateLights(List<TMP_Text> lights, string state, float time)
|
||||
{
|
||||
int timeInt = Mathf.CeilToInt(time);
|
||||
|
|
Loading…
Reference in New Issue