This commit is contained in:
parent
4edac872ac
commit
50143c5269
|
|
@ -9,8 +9,8 @@ Material:
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_Name: honglvdengjiantou_lv_you
|
m_Name: honglvdengjiantou_lv_you
|
||||||
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
|
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
m_ShaderKeywords: _EMISSION
|
m_ShaderKeywords:
|
||||||
m_LightmapFlags: 2
|
m_LightmapFlags: 4
|
||||||
m_EnableInstancingVariants: 0
|
m_EnableInstancingVariants: 0
|
||||||
m_DoubleSidedGI: 0
|
m_DoubleSidedGI: 0
|
||||||
m_CustomRenderQueue: -1
|
m_CustomRenderQueue: -1
|
||||||
|
|
|
||||||
|
|
@ -167662,7 +167662,7 @@ GameObject:
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
m_IsActive: 1
|
m_IsActive: 0
|
||||||
--- !u!114 &528661332
|
--- !u!114 &528661332
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -370568,7 +370568,7 @@ GameObject:
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
m_IsActive: 1
|
m_IsActive: 0
|
||||||
--- !u!114 &1198207951
|
--- !u!114 &1198207951
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,6 @@ public class TrafficLightManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
if (light != null)
|
if (light != null)
|
||||||
{
|
{
|
||||||
// 假设你有一个方法来根据状态获取相应的贴图
|
|
||||||
//Texture newTexture = GetTextureForState(state);
|
//Texture newTexture = GetTextureForState(state);
|
||||||
light.transform.Find("red2").GetComponent<MeshRenderer>().material.DisableKeyword("_EMISSION");
|
light.transform.Find("red2").GetComponent<MeshRenderer>().material.DisableKeyword("_EMISSION");
|
||||||
light.transform.Find("yellow1").GetComponent<MeshRenderer>().material.DisableKeyword("_EMISSION");
|
light.transform.Find("yellow1").GetComponent<MeshRenderer>().material.DisableKeyword("_EMISSION");
|
||||||
|
|
@ -57,7 +56,6 @@ public class TrafficLightManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
if (light != null)
|
if (light != null)
|
||||||
{
|
{
|
||||||
// 假设你有一个方法来根据状态获取相应的贴图
|
|
||||||
//Texture newTexture = GetTextureForState(state);
|
//Texture newTexture = GetTextureForState(state);
|
||||||
light.transform.Find("red2").GetComponent<MeshRenderer>().material.EnableKeyword("_EMISSION");
|
light.transform.Find("red2").GetComponent<MeshRenderer>().material.EnableKeyword("_EMISSION");
|
||||||
}
|
}
|
||||||
|
|
@ -74,7 +72,6 @@ public class TrafficLightManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
if (light != null)
|
if (light != null)
|
||||||
{
|
{
|
||||||
// 假设你有一个方法来根据状态获取相应的贴图
|
|
||||||
//Texture newTexture = GetTextureForState(state);
|
//Texture newTexture = GetTextureForState(state);
|
||||||
light.transform.Find("yellow1").GetComponent<MeshRenderer>().material.EnableKeyword("_EMISSION");
|
light.transform.Find("yellow1").GetComponent<MeshRenderer>().material.EnableKeyword("_EMISSION");
|
||||||
}
|
}
|
||||||
|
|
@ -86,7 +83,6 @@ public class TrafficLightManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
if (light != null)
|
if (light != null)
|
||||||
{
|
{
|
||||||
// 假设你有一个方法来根据状态获取相应的贴图
|
|
||||||
//Texture newTexture = GetTextureForState(state);
|
//Texture newTexture = GetTextureForState(state);
|
||||||
light.transform.Find("green2").GetComponent<MeshRenderer>().material.EnableKeyword("_EMISSION");
|
light.transform.Find("green2").GetComponent<MeshRenderer>().material.EnableKeyword("_EMISSION");
|
||||||
}
|
}
|
||||||
|
|
@ -103,11 +99,7 @@ public class TrafficLightManager : MonoBehaviour
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// private Texture GetTextureForState(TrafficLightState state)
|
|
||||||
// {
|
|
||||||
// // 返回根据 state 获取的贴图
|
|
||||||
// // 这里你需要根据你的资源来实现具体的逻辑
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TrafficLightGroup> lightGroups;
|
public List<TrafficLightGroup> lightGroups;
|
||||||
|
|
@ -124,12 +116,8 @@ public class TrafficLightManager : MonoBehaviour
|
||||||
|
|
||||||
void FixedUpdate()
|
void FixedUpdate()
|
||||||
{
|
{
|
||||||
// Debug.Log("Delta Time: " + Time.deltaTime);
|
|
||||||
foreach (var group in lightGroups)
|
foreach (var group in lightGroups)
|
||||||
{
|
{
|
||||||
// Debug.Log("Before: " + group.timer);
|
|
||||||
// group.timer -= Time.deltaTime;
|
|
||||||
// Debug.Log("After: " + group.timer);
|
|
||||||
|
|
||||||
// 更新红绿灯状态
|
// 更新红绿灯状态
|
||||||
UpdateTrafficLightGroup(group);
|
UpdateTrafficLightGroup(group);
|
||||||
|
|
@ -138,10 +126,7 @@ public class TrafficLightManager : MonoBehaviour
|
||||||
|
|
||||||
void AddRedLightWarning(TrafficLightGroup group)
|
void AddRedLightWarning(TrafficLightGroup group)
|
||||||
{
|
{
|
||||||
// 在这里添加提示或更改状态的逻辑
|
|
||||||
// 例如,你可以在红灯状态下播放声音或显示警告信息
|
|
||||||
|
|
||||||
// 以下是一个示例,在控制台输出警告信息:
|
|
||||||
Debug.LogWarning("红灯警告:请注意停车!");
|
Debug.LogWarning("红灯警告:请注意停车!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -182,7 +167,6 @@ public class TrafficLightManager : MonoBehaviour
|
||||||
void UpdateLights(List<TMP_Text> lights, string state, float time)
|
void UpdateLights(List<TMP_Text> lights, string state, float time)
|
||||||
{
|
{
|
||||||
int timeInt = Mathf.CeilToInt(time);
|
int timeInt = Mathf.CeilToInt(time);
|
||||||
// 使用条件运算符来判断是否需要在前面加上 0
|
|
||||||
string formattedTime = timeInt < 10 ? "0" + timeInt.ToString() : timeInt.ToString();
|
string formattedTime = timeInt < 10 ? "0" + timeInt.ToString() : timeInt.ToString();
|
||||||
string text = formattedTime;
|
string text = formattedTime;
|
||||||
Color color = Color.white;
|
Color color = Color.white;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue