From 50143c5269465944cc8268dc643d2dd95d9177a2 Mon Sep 17 00:00:00 2001 From: yzx Date: Wed, 17 Jan 2024 15:24:13 +0800 Subject: [PATCH] t --- .../Materials/honglvdengjiantou_lv_you.mat | 4 ++-- U3D_DrivingSystem/Assets/Scenes/main_.unity | 4 ++-- .../Assets/Script/TrafficLightManager.cs | 20 ++----------------- 3 files changed, 6 insertions(+), 22 deletions(-) diff --git a/U3D_DrivingSystem/Assets/GameAssets/Art/交通路标/Materials/honglvdengjiantou_lv_you.mat b/U3D_DrivingSystem/Assets/GameAssets/Art/交通路标/Materials/honglvdengjiantou_lv_you.mat index 4c5e9a5a..2d6fa209 100644 --- a/U3D_DrivingSystem/Assets/GameAssets/Art/交通路标/Materials/honglvdengjiantou_lv_you.mat +++ b/U3D_DrivingSystem/Assets/GameAssets/Art/交通路标/Materials/honglvdengjiantou_lv_you.mat @@ -9,8 +9,8 @@ Material: m_PrefabAsset: {fileID: 0} m_Name: honglvdengjiantou_lv_you m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} - m_ShaderKeywords: _EMISSION - m_LightmapFlags: 2 + m_ShaderKeywords: + m_LightmapFlags: 4 m_EnableInstancingVariants: 0 m_DoubleSidedGI: 0 m_CustomRenderQueue: -1 diff --git a/U3D_DrivingSystem/Assets/Scenes/main_.unity b/U3D_DrivingSystem/Assets/Scenes/main_.unity index fc7d76d5..c2440ce7 100644 --- a/U3D_DrivingSystem/Assets/Scenes/main_.unity +++ b/U3D_DrivingSystem/Assets/Scenes/main_.unity @@ -167662,7 +167662,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!114 &528661332 MonoBehaviour: m_ObjectHideFlags: 0 @@ -370568,7 +370568,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!114 &1198207951 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/U3D_DrivingSystem/Assets/Script/TrafficLightManager.cs b/U3D_DrivingSystem/Assets/Script/TrafficLightManager.cs index f35372d5..af8ee98d 100644 --- a/U3D_DrivingSystem/Assets/Script/TrafficLightManager.cs +++ b/U3D_DrivingSystem/Assets/Script/TrafficLightManager.cs @@ -42,7 +42,6 @@ public class TrafficLightManager : MonoBehaviour { if (light != null) { - // 假设你有一个方法来根据状态获取相应的贴图 //Texture newTexture = GetTextureForState(state); light.transform.Find("red2").GetComponent().material.DisableKeyword("_EMISSION"); light.transform.Find("yellow1").GetComponent().material.DisableKeyword("_EMISSION"); @@ -57,7 +56,6 @@ public class TrafficLightManager : MonoBehaviour { if (light != null) { - // 假设你有一个方法来根据状态获取相应的贴图 //Texture newTexture = GetTextureForState(state); light.transform.Find("red2").GetComponent().material.EnableKeyword("_EMISSION"); } @@ -74,7 +72,6 @@ public class TrafficLightManager : MonoBehaviour { if (light != null) { - // 假设你有一个方法来根据状态获取相应的贴图 //Texture newTexture = GetTextureForState(state); light.transform.Find("yellow1").GetComponent().material.EnableKeyword("_EMISSION"); } @@ -86,7 +83,6 @@ public class TrafficLightManager : MonoBehaviour { if (light != null) { - // 假设你有一个方法来根据状态获取相应的贴图 //Texture newTexture = GetTextureForState(state); light.transform.Find("green2").GetComponent().material.EnableKeyword("_EMISSION"); } @@ -103,11 +99,7 @@ public class TrafficLightManager : MonoBehaviour } } - // private Texture GetTextureForState(TrafficLightState state) - // { - // // 返回根据 state 获取的贴图 - // // 这里你需要根据你的资源来实现具体的逻辑 - // } + } public List lightGroups; @@ -124,12 +116,8 @@ public class TrafficLightManager : MonoBehaviour void FixedUpdate() { - // Debug.Log("Delta Time: " + Time.deltaTime); foreach (var group in lightGroups) { - // Debug.Log("Before: " + group.timer); - // group.timer -= Time.deltaTime; - // Debug.Log("After: " + group.timer); // 更新红绿灯状态 UpdateTrafficLightGroup(group); @@ -138,10 +126,7 @@ public class TrafficLightManager : MonoBehaviour void AddRedLightWarning(TrafficLightGroup group) { - // 在这里添加提示或更改状态的逻辑 - // 例如,你可以在红灯状态下播放声音或显示警告信息 - - // 以下是一个示例,在控制台输出警告信息: + Debug.LogWarning("红灯警告:请注意停车!"); } @@ -182,7 +167,6 @@ public class TrafficLightManager : MonoBehaviour void UpdateLights(List lights, string state, float time) { int timeInt = Mathf.CeilToInt(time); - // 使用条件运算符来判断是否需要在前面加上 0 string formattedTime = timeInt < 10 ? "0" + timeInt.ToString() : timeInt.ToString(); string text = formattedTime; Color color = Color.white;