This commit is contained in:
yzx 2023-12-22 18:10:03 +08:00
parent ce408baab3
commit 7ecbdab97a
9 changed files with 5087 additions and 109 deletions

View File

@ -620,6 +620,7 @@
<None Include="Assets\Plugin\Standard Assets\Effects\ImageEffects\Shaders\NoiseEffectShaderRGB.shader" />
<None Include="Assets\Plugin\Hard Surface Pro\HardSurface Shaders\HardSurface Pro Draw Last Transparent Diffuse.shader" />
<None Include="Assets\Plugin\Hard Surface Pro\HardSurface Shaders\HardSurface Pro Transparent Specular.shader" />
<None Include="Assets\GameAssets\Art\建筑模型\学校\红旗.shader" />
<None Include="Assets\BOXOPHOBIC\Atmospheric Height Fog\Core\Includes\AtmosphericHeightFog.cginc" />
<None Include="Assets\Plugin\Standard Assets\Environment\Water (Basic)\Shaders\FXWaterBasic.shader" />
<None Include="Assets\Plugin\Hard Surface Pro\HardSurface Shaders\HardSurface Draw Last Transparent Specular.shader" />

View File

@ -0,0 +1,79 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: xuexiao_d
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
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
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
m_BuildTextureStacks: []

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1ec6fcc62f1ac6140b89dfff32cd6e3d
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -7,7 +7,7 @@ Material:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: New Material
m_Name: "\u56FD\u65D7"
m_Shader: {fileID: 4800000, guid: 7d2cfe76d3164c64a94572066cca7bf3, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
@ -55,6 +55,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
@ -75,3 +76,4 @@ Material:
m_Colors:
- _Color: {r: 1, g: 0, b: 0, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
m_BuildTextureStacks: []

File diff suppressed because it is too large Load Diff

View File

@ -28,27 +28,32 @@ namespace Script
float maxValue = 900; // 范围的最大值
public CarInfoManager carInfoManager;
private ModbusTcpClient client;
private int NewValue = -1;
public GameObject thirdPerson;//第三人称
public GameObject firstPerson;//第一人称
void Start()
{
vehicleController = GetComponent<VehicleController>();
vehicleStandardInput = GetComponent<VehicleStandardInput>();
// StartModbus();
StartModbus();
ModBusQueue();
}
// async Task StartModbus()
// {
// client = new ModbusTcpClient();
// await client.ConnectToServer();
// while (true)
// {
// await client.SendModbusRequest();
//
// await Task.Delay(TimeSpan.FromSeconds(.1));
// }
// }
async Task StartModbus()
{
client = new ModbusTcpClient();
await client.ConnectToServer();
while (true)
{
await client.SendModbusRequest();
await Task.Delay(TimeSpan.FromSeconds(.1));
}
}
// void OnDestroy()
// {
@ -60,11 +65,16 @@ namespace Script
while (true)
{
// Debug.Log(client.modbusQueue.Count);
if (ModbusTcpClient.modbusTcpClient.modbusQueue.Count > 0)
if (client.modbusQueue.Count > 0)
{
carData = ModbusTcpClient.modbusTcpClient.modbusQueue.Dequeue();
carData = client.modbusQueue.Dequeue();
Debug.Log(vehicleController.steerInput);
//方向盘
vehicleController.steerInput = NormalizeValue(carData.SteeringWheelAngle, minValue, maxValue);
//手刹
@ -135,6 +145,21 @@ namespace Script
break;
}
}
//上1,右2,下3左4
if (NewValue != carData.ButtonData)
{
NewValue = carData.ButtonData;
CarMenuButton(NewValue);
}
else
{
continue;
}
}
await Task.Delay(TimeSpan.FromSeconds(.1));
@ -142,6 +167,25 @@ namespace Script
}
void CarMenuButton(int bt)
{
if (bt == 3)
{
if (thirdPerson.activeInHierarchy)
{
thirdPerson.SetActive(false);
firstPerson.SetActive(true);
}
else
{
thirdPerson.SetActive(true);
firstPerson.SetActive(false);
}
}
}
void Update()
{
// 检测并更新挡位

View File

@ -64,11 +64,11 @@ namespace ModbusManager
CloseConnection();
}
// public ModbusTcpClient()
// {
// tcpClient = new TcpClient();
// modbusQueue = new Queue<CarStatusData>();
// }
public ModbusTcpClient()
{
tcpClient = new TcpClient();
modbusQueue = new Queue<CarStatusData>();
}
/// <summary>
/// 接口为TCP/IP接口。
@ -157,7 +157,7 @@ namespace ModbusManager
carStatusData.IgnitionSwitch = dataValue;
break;
case 1://左打方向盘为负数右打方向盘为正数打方向盘打死一圈半数值1500。
// Debug.Log($"方向盘数据: {(short)dataValue}");
Debug.Log($"方向盘数据: {(short)dataValue}");
carStatusData.SteeringWheelAngle = (short)dataValue;
break;
case 2://01为喇叭按下

View File

@ -75,7 +75,7 @@ public class SteeringWheelController : MonoBehaviour
{
CarStatusData carData = ModbusTcpClient.modbusTcpClient.modbusQueue.Dequeue();
if (carData.ClutchPedalPosition > 30)
if (carData.AcceleratorPedalPosition > 30)
{
if (ClutchPedalPositionBool)
{
@ -83,7 +83,7 @@ public class SteeringWheelController : MonoBehaviour
SelectButton();
}
}
else if(carData.ClutchPedalPosition<30)
else if(carData.AcceleratorPedalPosition<=0)
{
ClutchPedalPositionBool = true;
}

View File

@ -12,14 +12,14 @@ EditorUserSettings:
value: 22424703114646680e0b0227036c5b151b18563f22213229
flags: 0
RecentlyUsedScenePath-2:
value: 22424703114646680e0b0227036c52111f19276439262f2434
flags: 0
RecentlyUsedScenePath-3:
value: 22424703114646680e0b0227036c52151802563f22213229
flags: 0
RecentlyUsedScenePath-4:
RecentlyUsedScenePath-3:
value: 22424703114646680e0b0227036c4c0417050c6439262f2434
flags: 0
RecentlyUsedScenePath-4:
value: 22424703114646680e0b0227036c52111f19276439262f2434
flags: 0
vcSharedLogLevel:
value: 0d5e400f0650
flags: 0