Compare commits

...

2 Commits

Author SHA1 Message Date
yzx 9afc37a146 Merge branch 'master' of http://172.16.1.12/huangjiayu/H_SafeExperienceDrivingSystem
# Conflicts:
#	U3D_DrivingSystem/Assembly-CSharp.csproj
#	U3D_DrivingSystem/Assets/Scenes/main_.unity
2023-12-26 10:11:33 +08:00
yzx 58d8b150fe tijiao 2023-12-26 10:11:09 +08:00
21 changed files with 12608 additions and 35780 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 53d607575180a6743a42afef68de7d1e
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -10,7 +10,7 @@ Material:
m_Name: trafic_lights
m_Shader: {fileID: 47, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_LightmapFlags: 4
m_LightmapFlags: 6
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
@ -59,6 +59,7 @@ Material:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
@ -79,3 +80,4 @@ Material:
m_Colors:
- _Color: {r: 1, g: 0.9561808, b: 0, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 0}
m_BuildTextureStacks: []

View File

@ -94,7 +94,7 @@ Material:
m_Colors:
- _ClipRect: {r: -32767, g: -32767, b: 32767, a: 32767}
- _EnvMatrixRotation: {r: 0, g: 0, b: 0, a: 0}
- _FaceColor: {r: 2.9960785, g: 0, b: 0, a: 1}
- _FaceColor: {r: 4, g: 4, b: 4, a: 1}
- _GlowColor: {r: 0, g: 1, b: 0, a: 0.5}
- _MaskCoord: {r: 0, g: 0, b: 32767, a: 32767}
- _OutlineColor: {r: 0, g: 0, b: 0, a: 1}

View File

@ -0,0 +1,41 @@
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class InitialTrafficLightSequence : MonoBehaviour
{
public List<TMP_Text> trafficLightText; // 用于显示红绿灯状态的文本
public TrafficLightManager trafficLightManager; // 引用主交通灯管理器
private float initialRedTimer = 3.0f; // 初始红灯持续时间
void Start()
{
// 设置初始红灯
UpdateLight("红灯", initialRedTimer);
}
void Update()
{
if (initialRedTimer > 0)
{
initialRedTimer -= Time.deltaTime;
UpdateLight("红灯", initialRedTimer);
}
else
{
// 红灯结束,启动常规交通灯循环
trafficLightManager.enabled = true;
this.enabled = false; // 关闭当前脚本,避免重复调用
}
}
void UpdateLight(string state, float time)
{
foreach (var v in trafficLightText)
{
v.text = $"{state}\n{Mathf.CeilToInt(time)}秒";
v.color = state == "红灯" ? Color.red : Color.green;
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d19645646e2d4a438d4580f670248e98
timeCreated: 1703506717

View File

@ -0,0 +1,157 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using TMPro;
using UnityEngine;
public enum TrafficLightState
{
Red,
Yellow,
Green
}
public class TrafficLightManager : MonoBehaviour
{
[System.Serializable]
public class TrafficLightGroup
{
public List<TMP_Text> lights = new List<TMP_Text>();
public bool startsWithGreen; // 标记组是从绿灯开始还是红灯开始
public float timer; // 计时器
public TrafficLightState currentState;
public TrafficLightState previousState; // 新增字段,用于保存黄灯之前的状态
public List<GameObject> trafficLights = new List<GameObject>();
public void Initialize()
{
// 绿灯开始则设为10秒否则设为39秒
currentState = startsWithGreen ? TrafficLightState.Green : TrafficLightState.Red;
previousState = currentState; // 初始化时,之前的状态与当前状态相同
timer = startsWithGreen ? 10f : 39;
}
public void UpdateTrafficLightTexture(TrafficLightState state)
{
foreach (var light in trafficLights)
{
if (light != null)
{
// 假设你有一个方法来根据状态获取相应的贴图
//Texture newTexture = GetTextureForState(state);
//light.GetComponent<Renderer>().material.mainTexture = newTexture;
}
}
}
// private Texture GetTextureForState(TrafficLightState state)
// {
// // 返回根据 state 获取的贴图
// // 这里你需要根据你的资源来实现具体的逻辑
// }
}
public List<TrafficLightGroup> lightGroups;
void Start()
{
// 初始化每组红绿灯的计时器
foreach (var group in lightGroups)
{
group.Initialize();
}
}
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);
}
}
void UpdateTrafficLightGroup(TrafficLightGroup group)
{
group.timer -= Time.deltaTime;
if (group.timer <= 0f)
{
switch (group.currentState)
{
case TrafficLightState.Green:
group.previousState = TrafficLightState.Green;
group.currentState = TrafficLightState.Yellow;
group.timer = 3f; // 黄灯持续时间
break;
case TrafficLightState.Yellow:
if (group.previousState == TrafficLightState.Green)
{
group.currentState = TrafficLightState.Red;
// 如果初始是绿灯,红灯持续时间为 49 秒
group.timer = group.startsWithGreen ? 39 : 20;
}
else
{
group.currentState = TrafficLightState.Green;
group.timer = 10f; // 绿灯持续时间
}
break;
case TrafficLightState.Red:
group.previousState = TrafficLightState.Red;
group.currentState = TrafficLightState.Yellow;
group.timer = 3f; // 黄灯持续时间
break;
}
}
// 更新交通灯显示
UpdateLights(group.lights, group.currentState.ToString(), group.timer);
group.UpdateTrafficLightTexture(group.currentState);
}
void UpdateLights(List<TMP_Text> 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;
switch (state)
{
case "Red":
color = Color.red;
break;
case "Yellow":
color = Color.yellow;
break;
case "Green":
color = Color.green;
break;
}
foreach (var light in lights)
{
if (light != null)
{
light.text = text;
light.color = color;
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a4e1f261be1c6ae4c9b2482187916877
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,4 +1,5 @@
using System.Collections;
using System.Threading.Tasks;
using UnityEngine;
public class OneWaySemaphoreSystem : SemaphoreSystem
@ -145,6 +146,7 @@ public class OneWaySemaphoreSystem : SemaphoreSystem
semaphore.ChangeYellow(true);
}
Debug.Log(this.name);
yield return new WaitForSeconds(yellowTime);
StartCoroutine(Green());
@ -159,10 +161,13 @@ public class OneWaySemaphoreSystem : SemaphoreSystem
semaphore.ChangeGreen(true);
}
countdownTime = greenTime;
Debug.Log(this.name);
yield return new WaitForSeconds(greenTime);
StartFlick();
}
public float countdownTime = 60.0f; // 设置倒计时的初始时间
public override IEnumerator YellowOff()
{
@ -187,7 +192,7 @@ public class OneWaySemaphoreSystem : SemaphoreSystem
{
semaphore.ChangeRed(true);
}
countdownTime = redTime;
yield return new WaitForSeconds(redTime);
ChangeSemaphoreState();

File diff suppressed because it is too large Load Diff

View File

@ -15,11 +15,11 @@ E:/Unity Projects/GitLab/2023/H_SafeExperienceDrivingSystem/U3D_DrivingSystem
-logFile
Logs/AssetImportWorker0.log
-srvPort
56142
65173
Successfully changed project path to: E:/Unity Projects/GitLab/2023/H_SafeExperienceDrivingSystem/U3D_DrivingSystem
E:/Unity Projects/GitLab/2023/H_SafeExperienceDrivingSystem/U3D_DrivingSystem
Using Asset Import Pipeline V2.
Refreshing native plugins compatible for Editor in 194.47 ms, found 8 plugins.
Refreshing native plugins compatible for Editor in 242.81 ms, found 8 plugins.
Preloading 0 native plugins for Editor in 0.00 ms.
Initialize engine version: 2021.1.24f1 (6667702a1e7c)
[Subsystems] Discovering subsystems at path D:/2021.1.24f1/Editor/Data/Resources/UnitySubsystems
@ -36,42 +36,42 @@ Initialize mono
Mono path[0] = 'D:/2021.1.24f1/Editor/Data/Managed'
Mono path[1] = 'D:/2021.1.24f1/Editor/Data/MonoBleedingEdge/lib/mono/unityjit'
Mono config path = 'D:/2021.1.24f1/Editor/Data/MonoBleedingEdge/etc'
Using monoOptions --debugger-agent=transport=dt_socket,embedding=1,server=y,suspend=n,address=127.0.0.1:56016
Using monoOptions --debugger-agent=transport=dt_socket,embedding=1,server=y,suspend=n,address=127.0.0.1:56948
Begin MonoManager ReloadAssembly
Registering precompiled unity dll's ...
Register platform support module: D:/2021.1.24f1/Editor/Data/PlaybackEngines/WindowsStandaloneSupport/UnityEditor.WindowsStandalone.Extensions.dll
Registered in 0.001001 seconds.
Registered in 0.000941 seconds.
Native extension for WindowsStandalone target not found
Refreshing native plugins compatible for Editor in 199.15 ms, found 8 plugins.
Refreshing native plugins compatible for Editor in 199.45 ms, found 8 plugins.
Preloading 0 native plugins for Editor in 0.00 ms.
Mono: successfully reloaded assembly
- Completed reload, in 1.932 seconds
- Completed reload, in 1.929 seconds
Domain Reload Profiling:
ReloadAssembly (1932ms)
BeginReloadAssembly (62ms)
ReloadAssembly (1929ms)
BeginReloadAssembly (65ms)
ExecutionOrderSort (0ms)
DisableScriptedObjects (0ms)
BackupInstance (0ms)
ReleaseScriptingObjects (0ms)
CreateAndSetChildDomain (1ms)
EndReloadAssembly (629ms)
LoadAssemblies (61ms)
EndReloadAssembly (612ms)
LoadAssemblies (64ms)
RebuildTransferFunctionScriptingTraits (0ms)
SetupTypeCache (173ms)
SetupTypeCache (162ms)
ReleaseScriptCaches (0ms)
RebuildScriptCaches (36ms)
SetupLoadedEditorAssemblies (369ms)
SetupLoadedEditorAssemblies (363ms)
LogAssemblyErrors (0ms)
InitializePlatformSupportModulesInManaged (7ms)
SetLoadedEditorAssemblies (0ms)
RefreshPlugins (199ms)
BeforeProcessingInitializeOnLoad (3ms)
ProcessInitializeOnLoadAttributes (112ms)
ProcessInitializeOnLoadMethodAttributes (47ms)
SetLoadedEditorAssemblies (1ms)
RefreshPlugins (200ms)
BeforeProcessingInitializeOnLoad (2ms)
ProcessInitializeOnLoadAttributes (109ms)
ProcessInitializeOnLoadMethodAttributes (44ms)
AfterProcessingInitializeOnLoad (0ms)
EditorAssembliesLoaded (0ms)
ExecutionOrderSort2 (0ms)
AwakeInstancesAfterBackupRestoration (0ms)
Platform modules already initialized, skipping
Registering precompiled user dll's ...
Registered in 0.006979 seconds.
Registered in 0.006905 seconds.

View File

@ -1,77 +0,0 @@
Using pre-set license
Built from '2021.1/staging' branch; Version is '2021.1.24f1 (6667702a1e7c) revision 6711152'; Using compiler version '192528614'; Build Type 'Release'
OS: 'Windows 10 Pro; OS build 19044.1682; Version 2009; 64bit' Language: 'zh' Physical Memory: 16197 MB
BatchMode: 1, IsHumanControllingUs: 0, StartBugReporterOnCrash: 0, Is64bit: 1, IsPro: 0
COMMAND LINE ARGUMENTS:
D:\2021.1.24f1\Editor\Unity.exe
-adb2
-batchMode
-noUpm
-name
AssetImportWorker1
-projectPath
E:/Unity Projects/GitLab/2023/H_SafeExperienceDrivingSystem/U3D_DrivingSystem
-logFile
Logs/AssetImportWorker1.log
-srvPort
56965
Successfully changed project path to: E:/Unity Projects/GitLab/2023/H_SafeExperienceDrivingSystem/U3D_DrivingSystem
E:/Unity Projects/GitLab/2023/H_SafeExperienceDrivingSystem/U3D_DrivingSystem
Using Asset Import Pipeline V2.
Refreshing native plugins compatible for Editor in 187.97 ms, found 8 plugins.
Preloading 0 native plugins for Editor in 0.00 ms.
Initialize engine version: 2021.1.24f1 (6667702a1e7c)
[Subsystems] Discovering subsystems at path D:/2021.1.24f1/Editor/Data/Resources/UnitySubsystems
[Subsystems] Discovering subsystems at path E:/Unity Projects/GitLab/2023/H_SafeExperienceDrivingSystem/U3D_DrivingSystem/Assets
GfxDevice: creating device client; threaded=0; jobified=0
Direct3D:
Version: Direct3D 11.0 [level 11.1]
Renderer: NVIDIA GeForce GTX 1660 SUPER (ID=0x21c4)
Vendor: NVIDIA
VRAM: 5981 MB
Driver: 31.0.15.4617
Shader 'Custom/EVP Particles Alpha Blended Shadows': fallback shader 'Particles/Alpha Blended' not found
Initialize mono
Mono path[0] = 'D:/2021.1.24f1/Editor/Data/Managed'
Mono path[1] = 'D:/2021.1.24f1/Editor/Data/MonoBleedingEdge/lib/mono/unityjit'
Mono config path = 'D:/2021.1.24f1/Editor/Data/MonoBleedingEdge/etc'
Using monoOptions --debugger-agent=transport=dt_socket,embedding=1,server=y,suspend=n,address=127.0.0.1:56472
Begin MonoManager ReloadAssembly
Registering precompiled unity dll's ...
Register platform support module: D:/2021.1.24f1/Editor/Data/PlaybackEngines/WindowsStandaloneSupport/UnityEditor.WindowsStandalone.Extensions.dll
Registered in 0.001060 seconds.
Native extension for WindowsStandalone target not found
Refreshing native plugins compatible for Editor in 194.45 ms, found 8 plugins.
Preloading 0 native plugins for Editor in 0.00 ms.
Mono: successfully reloaded assembly
- Completed reload, in 1.220 seconds
Domain Reload Profiling:
ReloadAssembly (1220ms)
BeginReloadAssembly (57ms)
ExecutionOrderSort (0ms)
DisableScriptedObjects (0ms)
BackupInstance (0ms)
ReleaseScriptingObjects (0ms)
CreateAndSetChildDomain (1ms)
EndReloadAssembly (590ms)
LoadAssemblies (56ms)
RebuildTransferFunctionScriptingTraits (0ms)
SetupTypeCache (161ms)
ReleaseScriptCaches (0ms)
RebuildScriptCaches (35ms)
SetupLoadedEditorAssemblies (343ms)
LogAssemblyErrors (0ms)
InitializePlatformSupportModulesInManaged (7ms)
SetLoadedEditorAssemblies (0ms)
RefreshPlugins (195ms)
BeforeProcessingInitializeOnLoad (2ms)
ProcessInitializeOnLoadAttributes (108ms)
ProcessInitializeOnLoadMethodAttributes (32ms)
AfterProcessingInitializeOnLoad (0ms)
EditorAssembliesLoaded (0ms)
ExecutionOrderSort2 (0ms)
AwakeInstancesAfterBackupRestoration (0ms)
Platform modules already initialized, skipping
Registering precompiled user dll's ...
Registered in 0.006552 seconds.

View File

@ -15,11 +15,11 @@ E:/Unity Projects/GitLab/2023/H_SafeExperienceDrivingSystem/U3D_DrivingSystem
-logFile
Logs/AssetImportWorker1.log
-srvPort
56142
65173
Successfully changed project path to: E:/Unity Projects/GitLab/2023/H_SafeExperienceDrivingSystem/U3D_DrivingSystem
E:/Unity Projects/GitLab/2023/H_SafeExperienceDrivingSystem/U3D_DrivingSystem
Using Asset Import Pipeline V2.
Refreshing native plugins compatible for Editor in 219.13 ms, found 8 plugins.
Refreshing native plugins compatible for Editor in 203.08 ms, found 8 plugins.
Preloading 0 native plugins for Editor in 0.00 ms.
Initialize engine version: 2021.1.24f1 (6667702a1e7c)
[Subsystems] Discovering subsystems at path D:/2021.1.24f1/Editor/Data/Resources/UnitySubsystems
@ -36,42 +36,42 @@ Initialize mono
Mono path[0] = 'D:/2021.1.24f1/Editor/Data/Managed'
Mono path[1] = 'D:/2021.1.24f1/Editor/Data/MonoBleedingEdge/lib/mono/unityjit'
Mono config path = 'D:/2021.1.24f1/Editor/Data/MonoBleedingEdge/etc'
Using monoOptions --debugger-agent=transport=dt_socket,embedding=1,server=y,suspend=n,address=127.0.0.1:56844
Using monoOptions --debugger-agent=transport=dt_socket,embedding=1,server=y,suspend=n,address=127.0.0.1:56172
Begin MonoManager ReloadAssembly
Registering precompiled unity dll's ...
Register platform support module: D:/2021.1.24f1/Editor/Data/PlaybackEngines/WindowsStandaloneSupport/UnityEditor.WindowsStandalone.Extensions.dll
Registered in 0.001061 seconds.
Registered in 0.001093 seconds.
Native extension for WindowsStandalone target not found
Refreshing native plugins compatible for Editor in 196.73 ms, found 8 plugins.
Refreshing native plugins compatible for Editor in 206.37 ms, found 8 plugins.
Preloading 0 native plugins for Editor in 0.00 ms.
Mono: successfully reloaded assembly
- Completed reload, in 1.239 seconds
- Completed reload, in 1.256 seconds
Domain Reload Profiling:
ReloadAssembly (1239ms)
BeginReloadAssembly (76ms)
ReloadAssembly (1257ms)
BeginReloadAssembly (64ms)
ExecutionOrderSort (0ms)
DisableScriptedObjects (0ms)
BackupInstance (0ms)
ReleaseScriptingObjects (0ms)
CreateAndSetChildDomain (1ms)
EndReloadAssembly (598ms)
LoadAssemblies (75ms)
EndReloadAssembly (608ms)
LoadAssemblies (63ms)
RebuildTransferFunctionScriptingTraits (0ms)
SetupTypeCache (163ms)
SetupTypeCache (165ms)
ReleaseScriptCaches (0ms)
RebuildScriptCaches (36ms)
SetupLoadedEditorAssemblies (349ms)
SetupLoadedEditorAssemblies (357ms)
LogAssemblyErrors (0ms)
InitializePlatformSupportModulesInManaged (7ms)
SetLoadedEditorAssemblies (0ms)
RefreshPlugins (197ms)
RefreshPlugins (206ms)
BeforeProcessingInitializeOnLoad (2ms)
ProcessInitializeOnLoadAttributes (110ms)
ProcessInitializeOnLoadMethodAttributes (32ms)
ProcessInitializeOnLoadAttributes (108ms)
ProcessInitializeOnLoadMethodAttributes (33ms)
AfterProcessingInitializeOnLoad (0ms)
EditorAssembliesLoaded (0ms)
ExecutionOrderSort2 (0ms)
AwakeInstancesAfterBackupRestoration (0ms)
Platform modules already initialized, skipping
Registering precompiled user dll's ...
Registered in 0.007099 seconds.
Registered in 0.006569 seconds.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,6 @@
Base path: 'D:/2021.1.24f1/Editor/Data', plugins path 'D:/2021.1.24f1/Editor/Data/PlaybackEngines'
Cmd: initializeCompiler
Cmd: compileSnippet
insize=1415 file=Assets/DefaultResourcesExtra/Autodesk Interactive pass=FORWARD cachingPP=1 ppOnly=0 stripLineD=0 buildPlatform=19 rsLen=0 pKW=UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_COLORSPACE_GAMMA UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_LIGHTMAP_FULL_HDR UNITY_PASS_FORWARDBASE uKW=DIRECTIONAL LIGHTPROBE_SH _EMISSION dKW=FOG_LINEAR FOG_EXP FOG_EXP2 INSTANCING_ON _NORMALMAP _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _METALLICGLOSSMAP _SPECGLOSSMAP _DETAIL_MULX2 _SPECULARHIGHLIGHTS_OFF _GLOSSYREFLECTIONS_OFF _PARALLAXMAP SHADOWS_SHADOWMASK DYNAMICLIGHTMAP_ON LIGHTMAP_ON LIGHTMAP_SHADOW_MIXING DIRLIGHTMAP_COMBINED SHADOWS_SCREEN UNITY_NO_DXT5nm UNITY_ENABLE_NATIVE_SHADOW_LOOKUPS UNITY_METAL_SHADOWS_USE_POINT_FILTERING UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF2 UNITY_PBS_USE_BRDF3 UNITY_NO_FULL_STANDARD_SHADER UNITY_HARDWARE_TIER1 UNITY_HARDWARE_TIER2 UNITY_HARDWARE_TIER3 UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS UNITY_LIGHTMAP_DLDR_ENCODING UNITY_LIGHTMAP_RGBM_ENCODING UNITY_VIRTUAL_TEXTURING UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION UNITY_ASTC_NORMALMAP_ENCODING SHADER_API_GLES30 flags=0 lang=0 type=Fragment platform=d3d11 reqs=4075 mask=6 start=67 ok=1 outsize=6950

View File

@ -18,6 +18,9 @@ EditorUserSettings:
value: 22424703114646680e0b0227036c4c0417050c6439262f2434
flags: 0
RecentlyUsedScenePath-4:
value: 224247031146460a5c5f42371e2a4b09
flags: 0
RecentlyUsedScenePath-5:
value: 22424703114646680e0b0227036c52111f19276439262f2434
flags: 0
vcSharedLogLevel: