This commit is contained in:
yzx 2023-12-22 13:46:41 +08:00
parent 7ea6ef5529
commit 120f0fcb52
9 changed files with 2010 additions and 30 deletions

View File

@ -120832,7 +120832,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 0 m_IsActive: 1
--- !u!4 &1150478578 --- !u!4 &1150478578
Transform: Transform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -132595,7 +132595,7 @@ MonoBehaviour:
currentGear: 1 currentGear: 1
gearSpeeds: gearSpeeds:
- 0 - 0
- 20 - 5
- 40 - 40
- 60 - 60
xx: 0 xx: 0

View File

@ -358,7 +358,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 0 m_IsActive: 1
--- !u!224 &76095179 --- !u!224 &76095179
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -973,7 +973,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 0 m_IsActive: 1
--- !u!224 &570311457 --- !u!224 &570311457
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -1106,7 +1106,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 0 m_IsActive: 1
--- !u!224 &574599288 --- !u!224 &574599288
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -1509,7 +1509,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 0 m_IsActive: 1
--- !u!224 &748011624 --- !u!224 &748011624
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -1642,7 +1642,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 0 m_IsActive: 1
--- !u!224 &867050206 --- !u!224 &867050206
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -4057,7 +4057,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 0 m_IsActive: 1
--- !u!224 &1952163225 --- !u!224 &1952163225
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -24,8 +24,8 @@ namespace Script
private CarStatusData carData; private CarStatusData carData;
float minValue = -300f; // 范围的最小值 float minValue = -900f; // 范围的最小值
float maxValue = 300; // 范围的最大值 float maxValue = 900; // 范围的最大值
public CarInfoManager carInfoManager; public CarInfoManager carInfoManager;
@ -64,13 +64,14 @@ namespace Script
{ {
carData = ModbusTcpClient.modbusTcpClient.modbusQueue.Dequeue(); carData = ModbusTcpClient.modbusTcpClient.modbusQueue.Dequeue();
Debug.Log(vehicleController.steerInput);
//方向盘 //方向盘
vehicleController.steerInput = NormalizeValue(carData.SteeringWheelAngle, minValue, maxValue); vehicleController.steerInput = NormalizeValue(carData.SteeringWheelAngle, minValue, maxValue);
//手刹 //手刹
// vehicleController.throttleInput = carData.HandbrakeStatus == 0 ? 1 : 0; // vehicleController.throttleInput = carData.HandbrakeStatus == 0 ? 1 : 0;
//挡位 00空挡1前进档2倒挡3为P档 //挡位 00空挡1前进档2倒挡3为P档
//当钥匙为点火状态,才能启动车 //当钥匙为点火状态,才能启动车
if (carData.IgnitionSwitch == 2) if (carData.IgnitionSwitch == 1)
{ {
switch (carData.GearPosition) switch (carData.GearPosition)
{ {

View File

@ -26,18 +26,15 @@ public class MenuManager : MonoBehaviour
private void Awake() private void Awake()
{ {
instance = this; instance = this;
} }
private void Start() private void Start()
{ {
GetComponent<SteeringWheelController>().buttons = uiGames[currentStep].GetComponentsInChildren<Button>(); GetComponent<SteeringWheelController>().buttons = uiGames[currentStep].GetComponentsInChildren<Button>();
GetComponent<SteeringWheelController>().HighlightButton(0); GetComponent<SteeringWheelController>().HighlightButton(0);
GameInfo.instance.carSelectTypeInfo.Clear(); GameInfo.instance.carSelectTypeInfo.Clear();
} }
@ -47,12 +44,12 @@ public class MenuManager : MonoBehaviour
NextStep(); NextStep();
if ( GameInfo.instance.carSelectTypeInfo.Count() == 2) if (GameInfo.instance.carSelectTypeInfo.Count() == 2)
{ {
SceneManager.LoadScene("main_"); SceneManager.LoadScene("main_");
} }
foreach (var v in GameInfo.instance.carSelectTypeInfo) foreach (var v in GameInfo.instance.carSelectTypeInfo)
{ {
Debug.Log(v.Key + "--->" + v.Value); Debug.Log(v.Key + "--->" + v.Value);
} }
@ -71,9 +68,9 @@ public class MenuManager : MonoBehaviour
currentStep++; currentStep++;
uiGames[currentStep].SetActive(true); uiGames[currentStep].SetActive(true);
uiGames[currentStep].transform.GetChild(0).GetComponent<BtClick>().OnClickSprite(); uiGames[currentStep].transform.GetChild(0).GetComponent<BtClick>().OnClickSprite();
// Debug.Log(uiGames[currentStep].transform.GetChild(0).GetComponent<Button>()); // Debug.Log(uiGames[currentStep].transform.GetChild(0).GetComponent<Button>());
GetComponent<SteeringWheelController>().buttons = uiGames[currentStep].GetComponentsInChildren<Button>(); GetComponent<SteeringWheelController>().buttons = uiGames[currentStep].GetComponentsInChildren<Button>();
} }
@ -88,8 +85,11 @@ public class MenuManager : MonoBehaviour
uiGames[i].SetActive(false); uiGames[i].SetActive(false);
} }
var item = GameInfo.instance.carSelectTypeInfo.ElementAt( GameInfo.instance.carSelectTypeInfo.Count - 1); if (GameInfo.instance.carSelectTypeInfo.Count > 0)
GameInfo.instance.carSelectTypeInfo.Remove(item.Key); {
var item = GameInfo.instance.carSelectTypeInfo.ElementAt(GameInfo.instance.carSelectTypeInfo.Count - 1);
GameInfo.instance.carSelectTypeInfo.Remove(item.Key);
}
currentStep--; currentStep--;
uiGames[currentStep].SetActive(true); uiGames[currentStep].SetActive(true);

View File

@ -173,7 +173,7 @@ namespace ModbusManager
carStatusData.AcceleratorPedalPosition = dataValue; carStatusData.AcceleratorPedalPosition = dataValue;
break; break;
case 5://0-100,踩到底为100 case 5://0-100,踩到底为100
Debug.Log($"离合踏板数据: {dataValue}"); // Debug.Log($"离合踏板数据: {dataValue}");
carStatusData.ClutchPedalPosition = dataValue; carStatusData.ClutchPedalPosition = dataValue;
break; break;
case 6://01表示手刹有效 case 6://01表示手刹有效

View File

@ -29,6 +29,8 @@ public class SteeringWheelController : MonoBehaviour
private int NewValue = -1; private int NewValue = -1;
private bool ClutchPedalPositionBool = false;
private void Awake() private void Awake()
{ {
Instance = this; Instance = this;
@ -75,9 +77,17 @@ public class SteeringWheelController : MonoBehaviour
if (carData.ClutchPedalPosition > 30) if (carData.ClutchPedalPosition > 30)
{ {
SelectButton(); if (ClutchPedalPositionBool)
{
ClutchPedalPositionBool = false;
SelectButton();
}
} }
else if(carData.ClutchPedalPosition<30)
{
ClutchPedalPositionBool = true;
}
if (NewValue != carData.ButtonData) if (NewValue != carData.ButtonData)
{ {
NewValue = carData.ButtonData; NewValue = carData.ButtonData;
@ -88,10 +98,6 @@ public class SteeringWheelController : MonoBehaviour
} }
CheckSteeringWheelAngle(NewValue); CheckSteeringWheelAngle(NewValue);
} }
await Task.Delay(TimeSpan.FromSeconds(.1)); await Task.Delay(TimeSpan.FromSeconds(.1));

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,3 @@
Base path: 'D:/2021.1.24f1/Editor/Data', plugins path 'D:/2021.1.24f1/Editor/Data/PlaybackEngines'
Cmd: initializeCompiler

View File

@ -4,11 +4,12 @@
UnityConnectSettings: UnityConnectSettings:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
serializedVersion: 1 serializedVersion: 1
m_Enabled: 0 m_Enabled: 1
m_TestMode: 0 m_TestMode: 0
m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events
m_EventUrl: https://cdp.cloud.unity3d.com/v1/events m_EventUrl: https://cdp.cloud.unity3d.com/v1/events
m_ConfigUrl: https://config.uca.cloud.unity3d.com m_ConfigUrl: https://config.uca.cloud.unity3d.com
m_DashboardUrl: https://dashboard.unity3d.com
m_TestInitMode: 0 m_TestInitMode: 0
CrashReportingSettings: CrashReportingSettings:
m_EventUrl: https://perf-events.cloud.unity3d.com m_EventUrl: https://perf-events.cloud.unity3d.com