Merge branch 'master' of http://172.16.1.12/huangjiayu/H_SafeExperienceDrivingSystem
This commit is contained in:
commit
8ed677eb84
|
|
@ -28,6 +28,8 @@ public class VehicleStandardInputInspector : Editor
|
|||
EditorGUILayout.PropertyField(propThrottleAndBrakeInput);
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("steerAxis"));
|
||||
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("xxxxxx"));
|
||||
|
||||
VehicleStandardInput.ThrottleAndBrakeInput throttleAndBrakeInput = (VehicleStandardInput.ThrottleAndBrakeInput)propThrottleAndBrakeInput.enumValueIndex;
|
||||
|
||||
if (throttleAndBrakeInput == VehicleStandardInput.ThrottleAndBrakeInput.SeparateAxes)
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ namespace EVP
|
|||
if (Input.GetKeyDown(resetVehicleKey)) m_doReset = true;
|
||||
}
|
||||
|
||||
|
||||
// public float xxxxxx;
|
||||
void FixedUpdate()
|
||||
{
|
||||
if (target == null) return;
|
||||
|
|
@ -72,9 +72,11 @@ namespace EVP
|
|||
forwardInput = Mathf.Clamp01(Input.GetAxis(throttleAndBrakeAxis));
|
||||
reverseInput = Mathf.Clamp01(-Input.GetAxis(throttleAndBrakeAxis));
|
||||
}
|
||||
// Debug.Log("前轮控制左右的参数----->" + steerInput);
|
||||
// Debug.Log("往前的参数----->" + forwardInput);
|
||||
// Debug.Log("往后的参数----->" + reverseInput);
|
||||
|
||||
// forwardInput = xxxxxx;
|
||||
Debug.Log("前轮控制左右的参数----->" + steerInput);
|
||||
Debug.Log("往前的参数----->" + forwardInput);
|
||||
Debug.Log("往后的参数----->" + reverseInput);
|
||||
// Translate forward/reverse to vehicle input
|
||||
|
||||
float throttleInput = 0.0f;
|
||||
|
|
|
|||
|
|
@ -5041,7 +5041,7 @@ MonoBehaviour:
|
|||
m_Script: {fileID: 11500000, guid: 8b9a305e18de0c04dbd257a21cd47087, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
sharedProfile: {fileID: 11400000, guid: f43d47d2fc4e7ed4a86d86c669dc13df, type: 2}
|
||||
sharedProfile: {fileID: 0}
|
||||
isGlobal: 1
|
||||
blendDistance: 0
|
||||
weight: 1
|
||||
|
|
@ -8338,7 +8338,7 @@ GameObject:
|
|||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
m_IsActive: 0
|
||||
--- !u!114 &85993936
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -33912,7 +33912,7 @@ MonoBehaviour:
|
|||
motionGridSize: 64
|
||||
colorBlindnessType: 0
|
||||
colorBlindnessStrength: 1
|
||||
m_Resources: {fileID: 11400000, guid: d82512f9c8e5d4a4d938b575d47f88d4, type: 2}
|
||||
m_Resources: {fileID: 0}
|
||||
m_ShowToolkit: 0
|
||||
m_ShowCustomSorter: 0
|
||||
breakBeforeColorGrading: 0
|
||||
|
|
@ -107639,7 +107639,7 @@ MonoBehaviour:
|
|||
motionGridSize: 64
|
||||
colorBlindnessType: 0
|
||||
colorBlindnessStrength: 1
|
||||
m_Resources: {fileID: 11400000, guid: d82512f9c8e5d4a4d938b575d47f88d4, type: 2}
|
||||
m_Resources: {fileID: 0}
|
||||
m_ShowToolkit: 0
|
||||
m_ShowCustomSorter: 0
|
||||
breakBeforeColorGrading: 0
|
||||
|
|
|
|||
|
|
@ -1027,7 +1027,7 @@ MonoBehaviour:
|
|||
m_Calls:
|
||||
- m_Target: {fileID: 66285358}
|
||||
m_MethodName: NextStep
|
||||
m_Mode: 5
|
||||
m_Mode: 1
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
|
|
@ -2456,6 +2456,84 @@ CanvasRenderer:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1117454472}
|
||||
m_CullTransparentMesh: 0
|
||||
--- !u!1 &1134469707
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1134469708}
|
||||
- component: {fileID: 1134469710}
|
||||
- component: {fileID: 1134469709}
|
||||
m_Layer: 5
|
||||
m_Name: Text
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &1134469708
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1134469707}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1952163225}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &1134469709
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1134469707}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_FontData:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_FontSize: 14
|
||||
m_FontStyle: 0
|
||||
m_BestFit: 0
|
||||
m_MinSize: 10
|
||||
m_MaxSize: 40
|
||||
m_Alignment: 4
|
||||
m_AlignByGeometry: 0
|
||||
m_RichText: 1
|
||||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: Button
|
||||
--- !u!222 &1134469710
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1134469707}
|
||||
m_CullTransparentMesh: 0
|
||||
--- !u!1 &1157041859
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -3903,6 +3981,136 @@ MonoBehaviour:
|
|||
m_EditorClassIdentifier:
|
||||
clickSprite: {fileID: 21300000, guid: e094113ec4b791245855a3db608e8edb, type: 3}
|
||||
carType: 3
|
||||
--- !u!1 &1952163224
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1952163225}
|
||||
- component: {fileID: 1952163228}
|
||||
- component: {fileID: 1952163227}
|
||||
- component: {fileID: 1952163226}
|
||||
m_Layer: 5
|
||||
m_Name: Button (5)
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &1952163225
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1952163224}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 1134469708}
|
||||
m_Father: {fileID: 2124250625}
|
||||
m_RootOrder: 10
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 748.5, y: -496.4}
|
||||
m_SizeDelta: {x: 160, y: 30}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &1952163226
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1952163224}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Navigation:
|
||||
m_Mode: 3
|
||||
m_SelectOnUp: {fileID: 0}
|
||||
m_SelectOnDown: {fileID: 0}
|
||||
m_SelectOnLeft: {fileID: 0}
|
||||
m_SelectOnRight: {fileID: 0}
|
||||
m_Transition: 1
|
||||
m_Colors:
|
||||
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
|
||||
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
|
||||
m_ColorMultiplier: 1
|
||||
m_FadeDuration: 0.1
|
||||
m_SpriteState:
|
||||
m_HighlightedSprite: {fileID: 0}
|
||||
m_PressedSprite: {fileID: 0}
|
||||
m_SelectedSprite: {fileID: 0}
|
||||
m_DisabledSprite: {fileID: 0}
|
||||
m_AnimationTriggers:
|
||||
m_NormalTrigger: Normal
|
||||
m_HighlightedTrigger: Highlighted
|
||||
m_PressedTrigger: Pressed
|
||||
m_SelectedTrigger: Selected
|
||||
m_DisabledTrigger: Disabled
|
||||
m_Interactable: 1
|
||||
m_TargetGraphic: {fileID: 1952163227}
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 66285359}
|
||||
m_MethodName: BBB
|
||||
m_Mode: 1
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument:
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 2
|
||||
--- !u!114 &1952163227
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1952163224}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_Type: 1
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!222 &1952163228
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1952163224}
|
||||
m_CullTransparentMesh: 0
|
||||
--- !u!1 &2124250621
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -4003,6 +4211,7 @@ RectTransform:
|
|||
- {fileID: 574599288}
|
||||
- {fileID: 76095179}
|
||||
- {fileID: 867050206}
|
||||
- {fileID: 1952163225}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ public class BtClick : MonoBehaviour
|
|||
public CarType carType;
|
||||
private Image image;
|
||||
public event Action OnStartCompleted;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
image = this.GetComponent<Image>();
|
||||
|
|
@ -42,25 +43,20 @@ public class BtClick : MonoBehaviour
|
|||
// }
|
||||
|
||||
|
||||
this.GetComponent<Button>().onClick.AddListener(delegate
|
||||
{
|
||||
|
||||
GameManager.instance.UIClick(carType,this.name);
|
||||
OnClickSprite();
|
||||
|
||||
Debug.Log("123123");
|
||||
});
|
||||
this.GetComponent<Button>().onClick.AddListener(delegate { GameManager.instance.OnBtClick(carType, this.name); });
|
||||
|
||||
|
||||
// OnStartCompleted?.Invoke();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void OnClickSprite()
|
||||
{
|
||||
image.sprite = clickSprite;
|
||||
}
|
||||
|
||||
public void Cancel()
|
||||
public void OnCancel()
|
||||
{
|
||||
image.sprite = defaultSprite;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,12 @@ public class CarInfoManager : MonoBehaviour
|
|||
|
||||
#endregion
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
StartBlinking(leftIndicator);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打开车灯
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
|
|
@ -26,10 +27,8 @@ public class GameManager : MonoBehaviour
|
|||
|
||||
public GameObject[] uiGames;
|
||||
|
||||
public Button[] btList = new Button[] { };
|
||||
private List<string> stepValues = new List<string>(); // 保存每个步骤的值
|
||||
private int currentStep = 0; // 当前步骤索引
|
||||
private CarType carType;
|
||||
public Dictionary<CarType, string> carSelectTypeInfo = new Dictionary<CarType, string>();
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
|
|
@ -65,7 +64,10 @@ public class GameManager : MonoBehaviour
|
|||
// GetComponent<SteeringWheelController>().buttons = home;
|
||||
|
||||
|
||||
UIClick(CarType.首页, "");
|
||||
// UIClick(CarType.首页, "模拟驾驶体验");
|
||||
// NextStep("3");
|
||||
GetComponent<SteeringWheelController>().buttons = uiGames[currentStep].GetComponentsInChildren<Button>();
|
||||
GetComponent<SteeringWheelController>().HighlightButton(0);
|
||||
}
|
||||
|
||||
// private IEnumerator WaitForBtClickStarts()
|
||||
|
|
@ -88,64 +90,24 @@ public class GameManager : MonoBehaviour
|
|||
// }
|
||||
|
||||
|
||||
public void SceneBts()
|
||||
public void OnBtClick(CarType carType, string btName)
|
||||
{
|
||||
Button[] buttonArray = new Button[] { };
|
||||
switch (carType)
|
||||
{
|
||||
case CarType.首页:
|
||||
buttonArray = uiGames[0].GetComponentsInChildren<Button>();
|
||||
break;
|
||||
case CarType.车类型:
|
||||
break;
|
||||
case CarType.天气:
|
||||
buttonArray = uiGames[1].GetComponentsInChildren<Button>();
|
||||
break;
|
||||
case CarType.危险驾驶:
|
||||
buttonArray = uiGames[2].GetComponentsInChildren<Button>();
|
||||
break;
|
||||
}
|
||||
carSelectTypeInfo.Add(carType, btName);
|
||||
|
||||
btList = buttonArray;
|
||||
}
|
||||
NextStep();
|
||||
|
||||
|
||||
public void UIClick(CarType ct, string btName)
|
||||
foreach (var v in carSelectTypeInfo)
|
||||
{
|
||||
carType = ct;
|
||||
|
||||
SceneBts();
|
||||
|
||||
for (int i = 0; i < btList.Length; i++)
|
||||
{
|
||||
if (btList[i].name == btName)
|
||||
{
|
||||
btList[i].GetComponent<BtClick>().OnClickSprite();
|
||||
}
|
||||
else
|
||||
{
|
||||
btList[i].GetComponent<BtClick>().Cancel();
|
||||
}
|
||||
Debug.Log(v.Key + "--->" + v.Value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void NextStep(string value)
|
||||
public void NextStep()
|
||||
{
|
||||
if (currentStep >= uiGames.Length - 1)
|
||||
return;
|
||||
|
||||
if (currentStep < stepValues.Count)
|
||||
{
|
||||
// 更新当前步骤的值
|
||||
stepValues[currentStep] = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 添加新步骤的值
|
||||
stepValues.Add(value);
|
||||
}
|
||||
|
||||
for (int i = 0; i < uiGames.Length; i++)
|
||||
{
|
||||
uiGames[i].SetActive(false);
|
||||
|
|
@ -153,13 +115,11 @@ public class GameManager : MonoBehaviour
|
|||
|
||||
currentStep++;
|
||||
uiGames[currentStep].SetActive(true);
|
||||
DisplayCurrentStepValue();
|
||||
|
||||
|
||||
uiGames[currentStep].transform.GetChild(0).GetComponent<BtClick>().OnClickSprite();
|
||||
|
||||
// Debug.Log(uiGames[currentStep].transform.GetChild(0).GetComponent<Button>());
|
||||
GetComponent<SteeringWheelController>().buttons = btList;
|
||||
GetComponent<SteeringWheelController>().buttons = uiGames[currentStep].GetComponentsInChildren<Button>();
|
||||
}
|
||||
|
||||
// 调用这个方法来返回上一个步骤
|
||||
|
|
@ -172,29 +132,14 @@ public class GameManager : MonoBehaviour
|
|||
uiGames[i].SetActive(false);
|
||||
}
|
||||
|
||||
var item = carSelectTypeInfo.ElementAt(carSelectTypeInfo.Count - 1);
|
||||
carSelectTypeInfo.Remove(item.Key);
|
||||
|
||||
currentStep--;
|
||||
uiGames[currentStep].SetActive(true);
|
||||
// 移除当前步骤的值
|
||||
if (currentStep < stepValues.Count)
|
||||
{
|
||||
stepValues.RemoveAt(currentStep);
|
||||
}
|
||||
|
||||
DisplayCurrentStepValue();
|
||||
}
|
||||
|
||||
uiGames[currentStep].transform.GetChild(0).GetComponent<BtClick>().OnClickSprite();
|
||||
}
|
||||
|
||||
private void DisplayCurrentStepValue()
|
||||
{
|
||||
if (currentStep < stepValues.Count)
|
||||
{
|
||||
Debug.Log("Current Step: " + currentStep + ", Value: " + stepValues[currentStep]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Current Step: " + currentStep + ", No Value Yet");
|
||||
}
|
||||
GetComponent<SteeringWheelController>().buttons = uiGames[currentStep].GetComponentsInChildren<Button>();
|
||||
}
|
||||
}
|
||||
|
|
@ -61,6 +61,9 @@ public class ModbusTcpClient
|
|||
await ReadResponse(stream);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设备回复: 00 00 00 00 00 24 01 03 20 00 01 00 02 00 03 00 04 00 05 00 06 00 07 00 08 00 09 00 0A 00 0B 00 0C 00 0D 00 0E 00 0F 00 10
|
||||
/// "00 00 00 00 00 24" 为TCP报文头,24 表示后面有三十六个字节。
|
||||
|
|
@ -69,16 +72,17 @@ public class ModbusTcpClient
|
|||
/// "20" 表示后面有三十二个字节数据,即16个数据。
|
||||
/// 后续数据为硬件反馈回来的数据:
|
||||
/// - "00 01" 为钥匙开关数据,0 熄火,1 通电,2 启动。
|
||||
/// - "00 02" 为方向盘数据。
|
||||
/// - "00 02"为方向盘数据,左打方向盘为负数,右打方向盘为正数,打方向盘幅度越大,绝对值越大。
|
||||
/// - "00 03" 为方向盘上喇叭状态,01 为喇叭按下。
|
||||
/// - "00 04" 为刹车踏板数据。
|
||||
/// - "00 05" 为油门踏板数据。
|
||||
/// - "00 06" 为离合踏板数据。
|
||||
/// - "00 04"为刹车踏板数据, 0-100,踩到底为100
|
||||
/// - "00 05" 为油门踏板数据。0-100,踩到底为100
|
||||
/// - "00 06" 为离合踏板数据。0-100,踩到底为100
|
||||
/// - "00 07" 为手刹数据,01 表示手刹有效。
|
||||
/// - "00 08" 为挡位数据,00 空挡,1 前进档,2 倒挡,3 为 P 档。
|
||||
/// - "00 09" 为雨刮数据,00 空档,1 手动一次雨刮,2 自动雨刮慢速,3 自动雨刮快速。
|
||||
/// - "00 0A" 为灯光数据,00 未开灯,1 近光,2 远光。
|
||||
/// - "00 0B" 为转向灯数据,00 未开转向灯,1 左转向灯,2 右转向灯。
|
||||
/// - "00 0C"为点火钥匙数据,00是熄火,1是通电,2是点火
|
||||
/// 后面为预留。
|
||||
/// </summary>
|
||||
private async Task ReadResponse(NetworkStream stream)
|
||||
|
|
@ -133,6 +137,9 @@ public class ModbusTcpClient
|
|||
case 10:
|
||||
Debug.Log($"转向灯状态: {dataValue}");
|
||||
break;
|
||||
case 11:
|
||||
Debug.Log($"点火钥匙数据: {dataValue}");
|
||||
break;
|
||||
default:
|
||||
Debug.Log($"预留数据 {i / 2 - 4}: {dataValue}");
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -1,15 +1,18 @@
|
|||
using System.Collections;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI; // 如果您使用的是UGUI
|
||||
|
||||
public class SteeringWheelController : MonoBehaviour
|
||||
{
|
||||
public Button[] buttons; // 您的UI按钮
|
||||
public static SteeringWheelController Instance;
|
||||
|
||||
public Button[] buttons;
|
||||
private int selectedButtonIndex = 0; // 当前选中的按钮索引
|
||||
private bool hasSelected = false; // 是否已经进行了选择
|
||||
|
||||
// 假设这是从硬件获取的方向盘角度
|
||||
// 硬件获取的方向盘角度
|
||||
private float steeringWheelAngle;
|
||||
|
||||
// 方向盘选择角度阈值和中立阈值
|
||||
|
|
@ -19,6 +22,12 @@ public class SteeringWheelController : MonoBehaviour
|
|||
|
||||
public float testFloatV;
|
||||
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
// 更新方向盘角度
|
||||
|
|
@ -33,20 +42,29 @@ public class SteeringWheelController : MonoBehaviour
|
|||
{
|
||||
testFloatV = 45;
|
||||
}
|
||||
|
||||
public void AAAA()
|
||||
{
|
||||
testFloatV = 0;
|
||||
}
|
||||
|
||||
public void BBB()
|
||||
{
|
||||
testFloatV = -45;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新方向盘角度
|
||||
/// </summary>
|
||||
private void UpdateSteeringWheelAngle()
|
||||
{
|
||||
// 这里需要替换成获取硬件方向盘角度的代码
|
||||
steeringWheelAngle = testFloatV;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断方向盘左边还是右边
|
||||
/// </summary>
|
||||
private void CheckSteeringWheelAngle()
|
||||
{
|
||||
if (Mathf.Abs(steeringWheelAngle) < neutralAngleThreshold)
|
||||
|
|
@ -72,6 +90,9 @@ public class SteeringWheelController : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下一个按钮
|
||||
/// </summary>
|
||||
private void SelectNextButton()
|
||||
{
|
||||
selectedButtonIndex = (selectedButtonIndex + 1) % buttons.Length;
|
||||
|
|
@ -79,6 +100,9 @@ public class SteeringWheelController : MonoBehaviour
|
|||
HighlightButton(selectedButtonIndex);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 上一个按钮
|
||||
/// </summary>
|
||||
private void SelectPreviousButton()
|
||||
{
|
||||
if (selectedButtonIndex == 0)
|
||||
|
|
@ -91,11 +115,44 @@ public class SteeringWheelController : MonoBehaviour
|
|||
HighlightButton(selectedButtonIndex);
|
||||
}
|
||||
|
||||
private void HighlightButton(int index)
|
||||
/// <summary>
|
||||
/// 选择按钮变换
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
public void HighlightButton(int index)
|
||||
{
|
||||
// 根据您的UI系统来高亮选中的按钮
|
||||
// 例如,在UGUI中,您可以改变按钮的颜色或添加一个高亮的边框
|
||||
buttons[index].GetComponent<Button>().onClick.Invoke();
|
||||
|
||||
for (int i = 0; i < buttons.Length; i++)
|
||||
{
|
||||
if (buttons[i].name == buttons[index].name)
|
||||
{
|
||||
buttons[i].GetComponent<BtClick>().OnClickSprite();
|
||||
}
|
||||
else
|
||||
{
|
||||
buttons[i].GetComponent<BtClick>().OnCancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// public void SelectButtonSprite( string btName)
|
||||
// {
|
||||
// for (int i = 0; i < buttons.Length; i++)
|
||||
// {
|
||||
// if (buttons[i].name == btName)
|
||||
// {
|
||||
// buttons[i].GetComponent<BtClick>().ClickSp();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// buttons[i].GetComponent<BtClick>().Cancel();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
public void SelectButton()
|
||||
{
|
||||
buttons[selectedButtonIndex].GetComponent<Button>().onClick.Invoke();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +1,13 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Script
|
||||
{
|
||||
public class test : MonoBehaviour
|
||||
{
|
||||
|
||||
|
||||
public Texture2D ttt;
|
||||
public void HHHH()
|
||||
{
|
||||
|
||||
|
|
@ -15,12 +16,16 @@ namespace Script
|
|||
|
||||
|
||||
private ModbusTcpClient client;
|
||||
public RawImage raw;
|
||||
private void Start()
|
||||
{
|
||||
|
||||
|
||||
hh();
|
||||
}
|
||||
|
||||
|
||||
|
||||
async void hh()
|
||||
{
|
||||
// 使用
|
||||
|
|
|
|||
|
|
@ -1218,9 +1218,8 @@ MonoBehaviour:
|
|||
m_Calls: []
|
||||
m_text: 152.6
|
||||
m_isRightToLeft: 0
|
||||
m_fontAsset: {fileID: 11400000, guid: dd21533292524214a8a014f0b278e2a0, type: 2}
|
||||
m_sharedMaterial: {fileID: -8234296794282158346, guid: dd21533292524214a8a014f0b278e2a0,
|
||||
type: 2}
|
||||
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||
m_fontSharedMaterials: []
|
||||
m_fontMaterial: {fileID: 0}
|
||||
m_fontMaterials: []
|
||||
|
|
@ -1537,6 +1536,7 @@ GameObject:
|
|||
- component: {fileID: 1365229777}
|
||||
- component: {fileID: 1365229776}
|
||||
- component: {fileID: 1365229775}
|
||||
- component: {fileID: 1365229778}
|
||||
m_Layer: 0
|
||||
m_Name: Main Camera
|
||||
m_TagString: MainCamera
|
||||
|
|
@ -1609,6 +1609,18 @@ Transform:
|
|||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &1365229778
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1365229774}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d33cfcb2d537466b9f33e73afa332c38, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1 &1426111765
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -1741,9 +1753,8 @@ MonoBehaviour:
|
|||
m_Calls: []
|
||||
m_text: 152.6
|
||||
m_isRightToLeft: 0
|
||||
m_fontAsset: {fileID: 11400000, guid: dd21533292524214a8a014f0b278e2a0, type: 2}
|
||||
m_sharedMaterial: {fileID: -8234296794282158346, guid: dd21533292524214a8a014f0b278e2a0,
|
||||
type: 2}
|
||||
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||
m_fontSharedMaterials: []
|
||||
m_fontMaterial: {fileID: 0}
|
||||
m_fontMaterials: []
|
||||
|
|
@ -1847,6 +1858,10 @@ PrefabInstance:
|
|||
m_Modification:
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 177328, guid: 4292160a5e1fde347934ac660b2c5d30, type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 198400, guid: 4292160a5e1fde347934ac660b2c5d30, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: Sport Coupe Drift
|
||||
|
|
|
|||
Loading…
Reference in New Issue