From 3e03b0ee3a9a4369c2166c9472254937dc890c7d Mon Sep 17 00:00:00 2001 From: yulong <1838206582@qq.com> Date: Mon, 28 Oct 2024 19:31:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Prefabs/烟箱_无动画 (1).prefab | 13 + Assets/Scenes/New Scene.unity | 74 ++ Assets/Scenes/TobaccoModelTest.unity | 308 ++------ Assets/Scripts/MqttManager.cs | 1028 ++++++++++++++++++++++++- Assets/Scripts/YL/CS.cs | 22 + Assets/Scripts/YL/CS.cs.meta | 11 + Assets/Scripts/YL/Detection.cs | 72 ++ Assets/Scripts/YL/Detection.cs.meta | 11 + Assets/Scripts/YL/Fetchbox.cs | 1 + Assets/Scripts/YL/Interaction.cs | 14 +- Assets/Scripts/YL/Loadingoperation.cs | 66 +- 11 files changed, 1334 insertions(+), 286 deletions(-) create mode 100644 Assets/Scripts/YL/CS.cs create mode 100644 Assets/Scripts/YL/CS.cs.meta create mode 100644 Assets/Scripts/YL/Detection.cs create mode 100644 Assets/Scripts/YL/Detection.cs.meta diff --git a/Assets/Prefabs/烟箱_无动画 (1).prefab b/Assets/Prefabs/烟箱_无动画 (1).prefab index cfa9517..b431e87 100644 --- a/Assets/Prefabs/烟箱_无动画 (1).prefab +++ b/Assets/Prefabs/烟箱_无动画 (1).prefab @@ -13,6 +13,7 @@ GameObject: - component: {fileID: 117189262902970689} - component: {fileID: 4979577903660582703} - component: {fileID: 1399729468017968744} + - component: {fileID: 4250281626495093301} m_Layer: 0 m_Name: "\u70DF\u7BB1_\u65E0\u52A8\u753B (1)" m_TagString: Box @@ -134,6 +135,18 @@ Rigidbody: m_Interpolate: 0 m_Constraints: 0 m_CollisionDetection: 0 +--- !u!114 &4250281626495093301 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1918721954697570452} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ef5411e111cb04441a761bc6cf9a1fc6, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &8394354781393860194 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/New Scene.unity b/Assets/Scenes/New Scene.unity index afdd92c..c2bba45 100644 --- a/Assets/Scenes/New Scene.unity +++ b/Assets/Scenes/New Scene.unity @@ -1649,6 +1649,75 @@ SkinnedMeshRenderer: m_CorrespondingSourceObject: {fileID: -1573408024702323732, guid: 4a0fa6ca7a7eaa04c9134d63238964d2, type: 3} m_PrefabInstance: {fileID: 307375476} m_PrefabAsset: {fileID: 0} +--- !u!1001 &1683417857 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + serializedVersion: 3 + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: -8679921383154817045, guid: fb7298f30cfa5ae4eaf512f471e507b5, type: 3} + propertyPath: m_LocalScale.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: fb7298f30cfa5ae4eaf512f471e507b5, type: 3} + propertyPath: m_LocalScale.y + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: fb7298f30cfa5ae4eaf512f471e507b5, type: 3} + propertyPath: m_LocalScale.z + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: fb7298f30cfa5ae4eaf512f471e507b5, type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: fb7298f30cfa5ae4eaf512f471e507b5, type: 3} + propertyPath: m_LocalPosition.y + value: 2.46 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: fb7298f30cfa5ae4eaf512f471e507b5, type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: fb7298f30cfa5ae4eaf512f471e507b5, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: fb7298f30cfa5ae4eaf512f471e507b5, type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: fb7298f30cfa5ae4eaf512f471e507b5, type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: fb7298f30cfa5ae4eaf512f471e507b5, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: fb7298f30cfa5ae4eaf512f471e507b5, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: fb7298f30cfa5ae4eaf512f471e507b5, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: fb7298f30cfa5ae4eaf512f471e507b5, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 919132149155446097, guid: fb7298f30cfa5ae4eaf512f471e507b5, type: 3} + propertyPath: m_Name + value: "\u5FEB\u6362\u7535\u6C601" + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: fb7298f30cfa5ae4eaf512f471e507b5, type: 3} --- !u!1 &1711450413 GameObject: m_ObjectHideFlags: 0 @@ -2005,6 +2074,10 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} + - target: {fileID: -3887185075125053422, guid: 206dceef219955f49832ac9a4681a85a, type: 3} + propertyPath: m_Enabled + value: 1 + objectReference: {fileID: 0} - target: {fileID: -3887185075125053422, guid: 206dceef219955f49832ac9a4681a85a, type: 3} propertyPath: m_DirtyAABB value: 0 @@ -2072,3 +2145,4 @@ SceneRoots: - {fileID: 2144222318} - {fileID: 1468853420} - {fileID: 1991611935} + - {fileID: 1683417857} diff --git a/Assets/Scenes/TobaccoModelTest.unity b/Assets/Scenes/TobaccoModelTest.unity index bbc3cb2..e6139d9 100644 --- a/Assets/Scenes/TobaccoModelTest.unity +++ b/Assets/Scenes/TobaccoModelTest.unity @@ -5762,6 +5762,7 @@ MonoBehaviour: firstbox: [] secondbox: [] speed: 5 + BoxID: {fileID: 1918721954697570452, guid: 3c5c67ef5f8f1da40b4a0efd25da6d96, type: 3} --- !u!114 &108631935 MonoBehaviour: m_ObjectHideFlags: 0 @@ -24166,11 +24167,11 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6148073173889382962, guid: 266ce14b00e8a694eae7fcaa9f961a0a, type: 3} propertyPath: m_Size.z - value: 0.26762486 + value: 0.20461154 objectReference: {fileID: 0} - target: {fileID: 6148073173889382962, guid: 266ce14b00e8a694eae7fcaa9f961a0a, type: 3} propertyPath: m_Enabled - value: 0 + value: 1 objectReference: {fileID: 0} - target: {fileID: 6148073173889382962, guid: 266ce14b00e8a694eae7fcaa9f961a0a, type: 3} propertyPath: m_Center.x @@ -24182,7 +24183,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6148073173889382962, guid: 266ce14b00e8a694eae7fcaa9f961a0a, type: 3} propertyPath: m_Center.z - value: 0.20404148 + value: 0.23554814 objectReference: {fileID: 0} - target: {fileID: 6148073173889382962, guid: 266ce14b00e8a694eae7fcaa9f961a0a, type: 3} propertyPath: m_IsTrigger @@ -36093,6 +36094,7 @@ MonoBehaviour: UICoverremovalmachine: {fileID: 617481942} boxbtn: {fileID: 1782092396} status: 0 + doubleClickTime: 0.3 --- !u!1 &798230193 GameObject: m_ObjectHideFlags: 0 @@ -54513,7 +54515,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6148073173889382962, guid: 266ce14b00e8a694eae7fcaa9f961a0a, type: 3} propertyPath: m_Size.z - value: 0.3470912 + value: 0.18967986 objectReference: {fileID: 0} - target: {fileID: 6148073173889382962, guid: 266ce14b00e8a694eae7fcaa9f961a0a, type: 3} propertyPath: m_Center.x @@ -54525,7 +54527,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6148073173889382962, guid: 266ce14b00e8a694eae7fcaa9f961a0a, type: 3} propertyPath: m_Center.z - value: 0.17430687 + value: 0.25301254 objectReference: {fileID: 0} - target: {fileID: 6148073173889382962, guid: 266ce14b00e8a694eae7fcaa9f961a0a, type: 3} propertyPath: m_IsTrigger @@ -58570,7 +58572,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6148073173889382962, guid: 266ce14b00e8a694eae7fcaa9f961a0a, type: 3} propertyPath: m_Size.z - value: 0.3818524 + value: 0.21634912 objectReference: {fileID: 0} - target: {fileID: 6148073173889382962, guid: 266ce14b00e8a694eae7fcaa9f961a0a, type: 3} propertyPath: m_Center.x @@ -58582,7 +58584,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6148073173889382962, guid: 266ce14b00e8a694eae7fcaa9f961a0a, type: 3} propertyPath: m_Center.z - value: 0.18335044 + value: 0.26610208 objectReference: {fileID: 0} - target: {fileID: 6148073173889382962, guid: 266ce14b00e8a694eae7fcaa9f961a0a, type: 3} propertyPath: m_IsTrigger @@ -64053,7 +64055,6 @@ Transform: - {fileID: 1567759124} - {fileID: 1739858987} - {fileID: 1324142881} - - {fileID: 1790865727} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1413371327 @@ -65410,7 +65411,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6148073173889382962, guid: 266ce14b00e8a694eae7fcaa9f961a0a, type: 3} propertyPath: m_Size.z - value: 0.30616048 + value: 0.21704179 objectReference: {fileID: 0} - target: {fileID: 6148073173889382962, guid: 266ce14b00e8a694eae7fcaa9f961a0a, type: 3} propertyPath: m_Center.x @@ -65422,7 +65423,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6148073173889382962, guid: 266ce14b00e8a694eae7fcaa9f961a0a, type: 3} propertyPath: m_Center.z - value: 0.18841757 + value: 0.23297691 objectReference: {fileID: 0} - target: {fileID: 6148073173889382962, guid: 266ce14b00e8a694eae7fcaa9f961a0a, type: 3} propertyPath: m_IsTrigger @@ -68388,8 +68389,6 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 1523578799} - - component: {fileID: 1523578801} - - component: {fileID: 1523578800} m_Layer: 0 m_Name: 8-37-2 m_TagString: Untagged @@ -68412,56 +68411,6 @@ Transform: m_Children: [] m_Father: {fileID: 543450651877670947} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!23 &1523578800 -MeshRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1523578798} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_DynamicOccludee: 1 - m_StaticShadowCaster: 0 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_RayTracingMode: 2 - m_RayTraceProcedural: 0 - m_RenderingLayerMask: 1 - m_RendererPriority: 0 - m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_ReceiveGI: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_StitchLightmapSeams: 1 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 - m_AdditionalVertexStreams: {fileID: 0} ---- !u!33 &1523578801 -MeshFilter: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1523578798} - m_Mesh: {fileID: -9123535487318109513, guid: 20cae80baf420364f85e9076858346c3, type: 3} --- !u!1 &1523806068 GameObject: m_ObjectHideFlags: 0 @@ -72327,7 +72276,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6148073173889382962, guid: 266ce14b00e8a694eae7fcaa9f961a0a, type: 3} propertyPath: m_Size.z - value: 0.33092827 + value: 0.20656383 objectReference: {fileID: 0} - target: {fileID: 6148073173889382962, guid: 266ce14b00e8a694eae7fcaa9f961a0a, type: 3} propertyPath: m_Center.x @@ -72339,7 +72288,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6148073173889382962, guid: 266ce14b00e8a694eae7fcaa9f961a0a, type: 3} propertyPath: m_Center.z - value: 0.17810833 + value: 0.24029055 objectReference: {fileID: 0} - target: {fileID: 6148073173889382962, guid: 266ce14b00e8a694eae7fcaa9f961a0a, type: 3} propertyPath: m_IsTrigger @@ -80083,111 +80032,6 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1790848023} m_CullTransparentMesh: 1 ---- !u!1 &1790865726 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1790865727} - - component: {fileID: 1790865730} - - component: {fileID: 1790865729} - - component: {fileID: 1790865728} - m_Layer: 0 - m_Name: 0-0-0 - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!4 &1790865727 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1790865726} - serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -18.61} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 1408424522} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!65 &1790865728 -BoxCollider: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1790865726} - m_Material: {fileID: 0} - m_IncludeLayers: - serializedVersion: 2 - m_Bits: 0 - m_ExcludeLayers: - serializedVersion: 2 - m_Bits: 0 - m_LayerOverridePriority: 0 - m_IsTrigger: 0 - m_ProvidesContacts: 0 - m_Enabled: 1 - serializedVersion: 3 - m_Size: {x: 1, y: 1, z: 1} - m_Center: {x: 0, y: 0, z: 0} ---- !u!23 &1790865729 -MeshRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1790865726} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_DynamicOccludee: 1 - m_StaticShadowCaster: 0 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_RayTracingMode: 2 - m_RayTraceProcedural: 0 - m_RenderingLayerMask: 1 - m_RendererPriority: 0 - m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_ReceiveGI: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_StitchLightmapSeams: 1 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 - m_AdditionalVertexStreams: {fileID: 0} ---- !u!33 &1790865730 -MeshFilter: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1790865726} - m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} --- !u!1 &1791832772 GameObject: m_ObjectHideFlags: 0 @@ -81731,6 +81575,67 @@ MeshFilter: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1812194013} m_Mesh: {fileID: 2133373475792414330, guid: 20cae80baf420364f85e9076858346c3, type: 3} +--- !u!1001 &1812991769 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + serializedVersion: 3 + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 117189262902970689, guid: 3c5c67ef5f8f1da40b4a0efd25da6d96, type: 3} + propertyPath: m_Materials.Array.data[0] + value: + objectReference: {fileID: 2100000, guid: c7b1effdb2765444da7b7a78a219cb4e, type: 2} + - target: {fileID: 1291261916664934958, guid: 3c5c67ef5f8f1da40b4a0efd25da6d96, type: 3} + propertyPath: m_LocalPosition.x + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 1291261916664934958, guid: 3c5c67ef5f8f1da40b4a0efd25da6d96, type: 3} + propertyPath: m_LocalPosition.y + value: 4.75 + objectReference: {fileID: 0} + - target: {fileID: 1291261916664934958, guid: 3c5c67ef5f8f1da40b4a0efd25da6d96, type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1291261916664934958, guid: 3c5c67ef5f8f1da40b4a0efd25da6d96, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 1291261916664934958, guid: 3c5c67ef5f8f1da40b4a0efd25da6d96, type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1291261916664934958, guid: 3c5c67ef5f8f1da40b4a0efd25da6d96, type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1291261916664934958, guid: 3c5c67ef5f8f1da40b4a0efd25da6d96, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1291261916664934958, guid: 3c5c67ef5f8f1da40b4a0efd25da6d96, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1291261916664934958, guid: 3c5c67ef5f8f1da40b4a0efd25da6d96, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1291261916664934958, guid: 3c5c67ef5f8f1da40b4a0efd25da6d96, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1918721954697570452, guid: 3c5c67ef5f8f1da40b4a0efd25da6d96, type: 3} + propertyPath: m_Name + value: "\u70DF\u7BB1_\u65E0\u52A8\u753B (1)" + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 3c5c67ef5f8f1da40b4a0efd25da6d96, type: 3} --- !u!1 &1814431761 GameObject: m_ObjectHideFlags: 0 @@ -88234,7 +88139,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6148073173889382962, guid: 266ce14b00e8a694eae7fcaa9f961a0a, type: 3} propertyPath: m_Size.z - value: 0.29657435 + value: 0.16984892 objectReference: {fileID: 0} - target: {fileID: 6148073173889382962, guid: 266ce14b00e8a694eae7fcaa9f961a0a, type: 3} propertyPath: m_Center.x @@ -88246,7 +88151,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6148073173889382962, guid: 266ce14b00e8a694eae7fcaa9f961a0a, type: 3} propertyPath: m_Center.z - value: 0.18831646 + value: 0.25167918 objectReference: {fileID: 0} - target: {fileID: 6148073173889382962, guid: 266ce14b00e8a694eae7fcaa9f961a0a, type: 3} propertyPath: m_IsTrigger @@ -91028,7 +90933,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6148073173889382962, guid: 266ce14b00e8a694eae7fcaa9f961a0a, type: 3} propertyPath: m_Size.z - value: 0.3396922 + value: 0.22530144 objectReference: {fileID: 0} - target: {fileID: 6148073173889382962, guid: 266ce14b00e8a694eae7fcaa9f961a0a, type: 3} propertyPath: m_Center.x @@ -91040,7 +90945,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6148073173889382962, guid: 266ce14b00e8a694eae7fcaa9f961a0a, type: 3} propertyPath: m_Center.z - value: 0.19196276 + value: 0.24915814 objectReference: {fileID: 0} - target: {fileID: 6148073173889382962, guid: 266ce14b00e8a694eae7fcaa9f961a0a, type: 3} propertyPath: m_IsTrigger @@ -91413,8 +91318,6 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 2027847628} - - component: {fileID: 2027847630} - - component: {fileID: 2027847629} m_Layer: 0 m_Name: 8-37-1 m_TagString: Untagged @@ -91437,56 +91340,6 @@ Transform: m_Children: [] m_Father: {fileID: 543450651877670947} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!23 &2027847629 -MeshRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2027847627} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_DynamicOccludee: 1 - m_StaticShadowCaster: 0 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_RayTracingMode: 2 - m_RayTraceProcedural: 0 - m_RenderingLayerMask: 1 - m_RendererPriority: 0 - m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_ReceiveGI: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_StitchLightmapSeams: 1 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 - m_AdditionalVertexStreams: {fileID: 0} ---- !u!33 &2027847630 -MeshFilter: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2027847627} - m_Mesh: {fileID: 4821748142028716696, guid: 20cae80baf420364f85e9076858346c3, type: 3} --- !u!1 &2028286645 GameObject: m_ObjectHideFlags: 0 @@ -148781,8 +148634,8 @@ BoxCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 3 - m_Size: {x: 0.98206663, y: 1.2633667, z: 0.29231662} - m_Center: {x: 0.025216818, y: 0.0051078796, z: 0.20148689} + m_Size: {x: 0.98206663, y: 1.2633667, z: 0.23787224} + m_Center: {x: 0.025216818, y: 0.0051078796, z: 0.22870907} --- !u!222 &8293918688537252195 CanvasRenderer: m_ObjectHideFlags: 0 @@ -153928,3 +153781,4 @@ SceneRoots: - {fileID: 108631931} - {fileID: 1291014530} - {fileID: 796359296} + - {fileID: 1812991769} diff --git a/Assets/Scripts/MqttManager.cs b/Assets/Scripts/MqttManager.cs index eda06e6..de0ab74 100644 --- a/Assets/Scripts/MqttManager.cs +++ b/Assets/Scripts/MqttManager.cs @@ -11,6 +11,7 @@ using DefaultNamespace; using DG.Tweening; using Newtonsoft.Json; using UnityEngine; +using UnityEngine.UIElements; public class MqttManager : MonoSingleton { @@ -65,7 +66,11 @@ public class MqttManager : MonoSingleton /// /// 小车位移的速度 /// - public float speed = 5f; + public float speed = 3.5f; + /// + /// 需要渲染的箱子0 + /// + public GameObject BoxID; [Obsolete] private void Awake() { @@ -134,10 +139,108 @@ public class MqttManager : MonoSingleton } break; case "ca": - Carequipment carequipment = JsonConvert.DeserializeObject(str.message); - string carname = str.device; - GameObject cargame = GameObject.Find(carname); - Carpoint(cargame, carequipment); + Debug.Log(str.message); + //Carequipment carequipment = JsonConvert.DeserializeObject(str.message); + switch (str.device) + { + case "car1": + Carequipment carequipment = JsonConvert.DeserializeObject(str.message); + //string carname = str.device; + Debug.Log(str.device); + GameObject cargame = GameObject.Find("car1"); + if (cargame) + { + Debug.Log("第一个小车运动"); + Carpoint(cargame, carequipment); + } + break; + case "car2": + Carequipment carequipment2 = JsonConvert.DeserializeObject(str.message); + //string carname = str.device; + Debug.Log(str.device); + GameObject cargame2 = GameObject.Find("car2"); + if (cargame2) + { + Debug.Log("第二个小车运动"); + Carpoint2(cargame2, carequipment2); + } + break; + case "car3": + Carequipment carequipment3 = JsonConvert.DeserializeObject(str.message); + //string carname = str.device; + Debug.Log(str.device); + GameObject cargame3 = GameObject.Find("car3"); + if (cargame3) + { + Debug.Log("第三个小车运动"); + Carpoint3(cargame3, carequipment3); + } + break; + case "car4": + Carequipment carequipment4 = JsonConvert.DeserializeObject(str.message); + //string carname = str.device; + Debug.Log(str.device); + GameObject cargame4 = GameObject.Find("car4"); + if (cargame4) + { + Debug.Log("第四个小车运动"); + Carpoint4(cargame4, carequipment4); + } + break; + case "car5": + Carequipment carequipment5 = JsonConvert.DeserializeObject(str.message); + //string carname = str.device; + Debug.Log(str.device); + GameObject cargame5 = GameObject.Find("car5"); + if (cargame5) + { + Debug.Log("第五个小车运动"); + Carpoint5(cargame5, carequipment5); + } + break; + case "car6": + Carequipment carequipment6 = JsonConvert.DeserializeObject(str.message); + //string carname = str.device; + Debug.Log(str.device); + GameObject cargame6 = GameObject.Find("car6"); + if (cargame6) + { + Debug.Log("第六个小车运动"); + Carpoint6(cargame6, carequipment6); + } + break; + case "car7": + Carequipment carequipment7 = JsonConvert.DeserializeObject(str.message); + //string carname = str.device; + Debug.Log(str.device); + GameObject cargame7 = GameObject.Find("car7"); + if (cargame7) + { + Debug.Log("第七个小车运动"); + Carpoint7(cargame7, carequipment7); + } + break; + case "car8": + Carequipment carequipment8 = JsonConvert.DeserializeObject(str.message); + //string carname = str.device; + Debug.Log(str.device); + GameObject cargame8 = GameObject.Find("car8"); + if (cargame8) + { + Debug.Log("第八个小车运动"); + Carpoint8(cargame8, carequipment8); + } + break; + default: + break; + } + //string carname = str.device; + //Debug.Log(str.device); + //GameObject cargame = GameObject.Find(carname); + //if (cargame) + //{ + // Carpoint(cargame, carequipment); + //} break; case "fe": Feequipment feequipment = JsonConvert.DeserializeObject(str.message); @@ -159,6 +262,10 @@ public class MqttManager : MonoSingleton } } } + /// + /// 第一个小车 + /// + int index = 1; public void Carpoint(GameObject car, Carequipment carequipment) { Debug.Log(carequipment.id); @@ -166,29 +273,903 @@ public class MqttManager : MonoSingleton { Carinformation carbox = car.GetComponent(); carbox.BoxCode = carequipment.CarState_BoxCode; - string point = carequipment.CarState_Car_Column + "-" + carequipment.CarState_Car_Row + "-" + carequipment.CarState_Car_Layer; + string point = carequipment.CarState_Car_Row + "-" + carequipment.CarState_Car_Column + "-" + carequipment.CarState_Car_Layer; + Debug.Log("打印小车点位" + point); + if (GameObject.Find(point)) + { + GameObject displacement = GameObject.Find(point); + if (displacement != null && index < 2) + { + car.transform.position = displacement.transform.position; + index++; + } + else if (displacement != null) + { + Debug.Log(index); + Designateddisplacement(car, displacement.transform.position, speed); + Debug.Log("小车位移到指定点位"); + } + } + if (carequipment.CarState_CarPlt == "2") + { + if (car.gameObject.transform.childCount == 0 && carequipment.CarState_BoxCode != "0") + { + if (BoxID) + { + GameObject box = Instantiate(BoxID, car.gameObject.transform); + Boxinformation boxinformation = box.AddComponent(); + boxinformation.ID = carequipment.CarState_BoxCode; + Debug.Log("小车身上没有箱子,克隆出来一个箱子" + carequipment.CarState_BoxCode); + if (box.gameObject != null) + { + // 获取触发器物体的碰撞体 + Collider triggerCollider = car.GetComponent(); - GameObject displacement = GameObject.Find(point); + // 确保触发器物体有碰撞体 + if (triggerCollider != null) + { + // 计算触发器物体顶部的世界坐标 + Vector3 triggerPosition = triggerCollider.bounds.center; + Vector3 triggerTop = triggerPosition + Vector3.up * (triggerCollider.bounds.extents.y); + + // 设置物体的位置 + box.gameObject.transform.localEulerAngles = new Vector3(90, 0, 0); + box.gameObject.transform.position = triggerTop; + box.gameObject.transform.SetParent(car.gameObject.transform, false); + + Debug.Log("箱子位置初始化"); + } + else + { + Debug.LogError("触发器没有碰撞体"); + } + } + if (carequipment.CarState_Car_Layer.Equals(1)) + { + GameObject childbox = box.transform.GetChild(0).gameObject; + MqttManager.Instance.firstbox.Add(childbox); + MqttManager.Instance.firstbox.Add(box); + } + else + { + GameObject childbox = box.transform.GetChild(0).gameObject; + MqttManager.Instance.secondbox.Add(childbox); + MqttManager.Instance.secondbox.Add(box); + } + } + } + } + else if (carequipment.CarState_CarPlt == "1") + { + Debug.Log("小车身上没有箱子"); + if (car.gameObject.transform.childCount > 0) + { + GameObject box = car.gameObject.transform.GetChild(0).gameObject; + box.gameObject.transform.DOMoveY(box.gameObject.transform.position.y + 0.2f, 0.4f).SetEase(Ease.InOutQuad).OnComplete(() => + { + if (box.GetComponent()) + { + Collider collider = box.GetComponent(); + if (collider) + { + collider.enabled = false; + Debug.Log("失活了箱子触发器"); + box.gameObject.transform.SetParent(null); + Debug.Log("把箱子父物体取消"); + } + Debug.Log("卸箱动画向上提"); + box.gameObject.transform.DOMoveY(box.gameObject.transform.position.y - 0.62f, 1f).SetEase(Ease.InOutQuad).OnComplete(() => + { + Debug.Log("卸箱动画向下提"); + }); + } + }); + } + } + //else + //{ + // BoxCollider cars = car.GetComponent(); + //} //car.transform.DOMove(displacement.transform.position, Vector3.Distance(car.transform.position, displacement.transform.position) / speed).SetEase(Ease.InOutQuad); - Designateddisplacement(car, displacement.transform.position, speed); - if (carequipment.CarState_CarPlt == "上升") - { - BoxCollider cars = car.GetComponent(); - cars.enabled = true; - } - else if (carequipment.CarState_CarPlt == "下降") - { - GameObject box = car.transform.GetChild(0).gameObject; - float dis = box.transform.position.y - 0.3f; - box.transform.DOMoveY(dis, 0.2f).SetEase(Ease.OutQuad); - car.transform.SetParent(null); - } - else + } + } + /// + /// 第二个小车 + /// + /// + /// + int index2 = 1; + public void Carpoint2(GameObject car, Carequipment carequipment) + { + Debug.Log(carequipment.id); + if (car) + { + Carinformation carbox = car.GetComponent(); + carbox.BoxCode = carequipment.CarState_BoxCode; + string point = carequipment.CarState_Car_Row + "-" + carequipment.CarState_Car_Column + "-" + carequipment.CarState_Car_Layer; + Debug.Log("打印小车点位" + point); + if (GameObject.Find(point)) { - BoxCollider cars = car.GetComponent(); - cars.enabled = false; + GameObject displacement = GameObject.Find(point); + if (displacement != null && index2 < 2) + { + car.transform.position = displacement.transform.position; + index2++; + } + else if (displacement != null) + { + Debug.Log(index3); + Designateddisplacement(car, displacement.transform.position, speed); + Debug.Log("小车位移到指定点位"); + } } + if (carequipment.CarState_CarPlt == "2") + { + if (car.gameObject.transform.childCount == 0 && carequipment.CarState_BoxCode != "0") + { + if (BoxID) + { + GameObject box = Instantiate(BoxID, car.gameObject.transform); + Boxinformation boxinformation = box.AddComponent(); + boxinformation.ID = carequipment.CarState_BoxCode; + Debug.Log("小车身上没有箱子,克隆出来一个箱子" + carequipment.CarState_BoxCode); + if (box.gameObject != null) + { + // 获取触发器物体的碰撞体 + Collider triggerCollider = car.GetComponent(); + + // 确保触发器物体有碰撞体 + if (triggerCollider != null) + { + // 计算触发器物体顶部的世界坐标 + Vector3 triggerPosition = triggerCollider.bounds.center; + Vector3 triggerTop = triggerPosition + Vector3.up * (triggerCollider.bounds.extents.y); + + // 设置物体的位置 + box.gameObject.transform.localEulerAngles = new Vector3(90, 0, 0); + box.gameObject.transform.position = triggerTop; + box.gameObject.transform.SetParent(car.gameObject.transform, false); + + Debug.Log("箱子位置初始化"); + } + else + { + Debug.LogError("触发器没有碰撞体"); + } + } + if (carequipment.CarState_Car_Layer.Equals(1)) + { + GameObject childbox = box.transform.GetChild(0).gameObject; + MqttManager.Instance.firstbox.Add(childbox); + MqttManager.Instance.firstbox.Add(box); + } + else + { + GameObject childbox = box.transform.GetChild(0).gameObject; + MqttManager.Instance.secondbox.Add(childbox); + MqttManager.Instance.secondbox.Add(box); + } + } + } + } + else if (carequipment.CarState_CarPlt == "1") + { + Debug.Log("小车身上没有箱子"); + if (car.gameObject.transform.childCount > 0) + { + GameObject box = car.gameObject.transform.GetChild(0).gameObject; + box.gameObject.transform.DOMoveY(box.gameObject.transform.position.y + 0.2f, 0.4f).SetEase(Ease.InOutQuad).OnComplete(() => + { + if (box.GetComponent()) + { + Collider collider = box.GetComponent(); + if (collider) + { + collider.enabled = false; + Debug.Log("失活了箱子触发器"); + box.gameObject.transform.SetParent(null); + Debug.Log("把箱子父物体取消"); + } + Debug.Log("卸箱动画向上提"); + box.gameObject.transform.DOMoveY(box.gameObject.transform.position.y - 0.62f, 1f).SetEase(Ease.InOutQuad).OnComplete(() => + { + Debug.Log("卸箱动画向下提"); + }); + } + }); + } + } + //else + //{ + // BoxCollider cars = car.GetComponent(); + //} + //car.transform.DOMove(displacement.transform.position, Vector3.Distance(car.transform.position, displacement.transform.position) / speed).SetEase(Ease.InOutQuad); + + } + } + /// + /// 第三个小车 + /// + /// + /// + int index3 = 1; + public void Carpoint3(GameObject car, Carequipment carequipment) + { + Debug.Log(carequipment.id); + if (car) + { + Carinformation carbox = car.GetComponent(); + carbox.BoxCode = carequipment.CarState_BoxCode; + string point = carequipment.CarState_Car_Row + "-" + carequipment.CarState_Car_Column + "-" + carequipment.CarState_Car_Layer; + Debug.Log("打印小车点位" + point); + if (GameObject.Find(point)) + { + GameObject displacement = GameObject.Find(point); + if (displacement != null && index3 < 2) + { + car.transform.position = displacement.transform.position; + index3++; + } + else if (displacement != null) + { + Debug.Log(index3); + Designateddisplacement(car, displacement.transform.position, speed); + Debug.Log("小车位移到指定点位"); + } + } + if (carequipment.CarState_CarPlt == "2") + { + if (car.gameObject.transform.childCount == 0 && carequipment.CarState_BoxCode != "0") + { + if (BoxID) + { + GameObject box = Instantiate(BoxID, car.gameObject.transform); + Boxinformation boxinformation = box.AddComponent(); + boxinformation.ID = carequipment.CarState_BoxCode; + Debug.Log("小车身上没有箱子,克隆出来一个箱子" + carequipment.CarState_BoxCode); + if (box.gameObject != null) + { + // 获取触发器物体的碰撞体 + Collider triggerCollider = car.GetComponent(); + + // 确保触发器物体有碰撞体 + if (triggerCollider != null) + { + // 计算触发器物体顶部的世界坐标 + Vector3 triggerPosition = triggerCollider.bounds.center; + Vector3 triggerTop = triggerPosition + Vector3.up * (triggerCollider.bounds.extents.y); + + // 设置物体的位置 + box.gameObject.transform.localEulerAngles = new Vector3(90, 0, 0); + box.gameObject.transform.position = triggerTop; + box.gameObject.transform.SetParent(car.gameObject.transform, false); + + Debug.Log("箱子位置初始化"); + } + else + { + Debug.LogError("触发器没有碰撞体"); + } + } + if (carequipment.CarState_Car_Layer.Equals(1)) + { + GameObject childbox = box.transform.GetChild(0).gameObject; + MqttManager.Instance.firstbox.Add(childbox); + MqttManager.Instance.firstbox.Add(box); + } + else + { + GameObject childbox = box.transform.GetChild(0).gameObject; + MqttManager.Instance.secondbox.Add(childbox); + MqttManager.Instance.secondbox.Add(box); + } + } + } + } + else if (carequipment.CarState_CarPlt == "1") + { + Debug.Log("小车身上没有箱子"); + if (car.gameObject.transform.childCount > 0) + { + GameObject box = car.gameObject.transform.GetChild(0).gameObject; + box.gameObject.transform.DOMoveY(box.gameObject.transform.position.y + 0.2f, 0.4f).SetEase(Ease.InOutQuad).OnComplete(() => + { + if (box.GetComponent()) + { + Collider collider = box.GetComponent(); + if (collider) + { + collider.enabled = false; + Debug.Log("失活了箱子触发器"); + box.gameObject.transform.SetParent(null); + Debug.Log("把箱子父物体取消"); + } + Debug.Log("卸箱动画向上提"); + box.gameObject.transform.DOMoveY(box.gameObject.transform.position.y - 0.62f, 1f).SetEase(Ease.InOutQuad).OnComplete(() => + { + Debug.Log("卸箱动画向下提"); + }); + } + }); + } + } + //else + //{ + // BoxCollider cars = car.GetComponent(); + //} + //car.transform.DOMove(displacement.transform.position, Vector3.Distance(car.transform.position, displacement.transform.position) / speed).SetEase(Ease.InOutQuad); + + } + } + /// + /// 第四个小车 + /// + /// + /// + int index4 = 1; + public void Carpoint4(GameObject car, Carequipment carequipment) + { + Debug.Log(carequipment.id); + if (car) + { + Carinformation carbox = car.GetComponent(); + carbox.BoxCode = carequipment.CarState_BoxCode; + string point = carequipment.CarState_Car_Row + "-" + carequipment.CarState_Car_Column + "-" + carequipment.CarState_Car_Layer; + Debug.Log("打印小车点位" + point); + if (GameObject.Find(point)) + { + GameObject displacement = GameObject.Find(point); + if (displacement != null && index4 < 2) + { + car.transform.position = displacement.transform.position; + index4++; + } + else if (displacement != null) + { + Debug.Log(index4); + Designateddisplacement(car, displacement.transform.position, speed); + Debug.Log("小车位移到指定点位"); + } + } + if (carequipment.CarState_CarPlt == "2") + { + if (car.gameObject.transform.childCount == 0 && carequipment.CarState_BoxCode != "0") + { + if (BoxID) + { + GameObject box = Instantiate(BoxID, car.gameObject.transform); + Boxinformation boxinformation = box.AddComponent(); + boxinformation.ID = carequipment.CarState_BoxCode; + Debug.Log("小车身上没有箱子,克隆出来一个箱子" + carequipment.CarState_BoxCode); + if (box.gameObject != null) + { + // 获取触发器物体的碰撞体 + Collider triggerCollider = car.GetComponent(); + + // 确保触发器物体有碰撞体 + if (triggerCollider != null) + { + // 计算触发器物体顶部的世界坐标 + Vector3 triggerPosition = triggerCollider.bounds.center; + Vector3 triggerTop = triggerPosition + Vector3.up * (triggerCollider.bounds.extents.y); + + // 设置物体的位置 + box.gameObject.transform.localEulerAngles = new Vector3(90, 0, 0); + box.gameObject.transform.position = triggerTop; + box.gameObject.transform.SetParent(car.gameObject.transform, false); + + Debug.Log("箱子位置初始化"); + } + else + { + Debug.LogError("触发器没有碰撞体"); + } + } + if (carequipment.CarState_Car_Layer.Equals(1)) + { + GameObject childbox = box.transform.GetChild(0).gameObject; + MqttManager.Instance.firstbox.Add(childbox); + MqttManager.Instance.firstbox.Add(box); + } + else + { + GameObject childbox = box.transform.GetChild(0).gameObject; + MqttManager.Instance.secondbox.Add(childbox); + MqttManager.Instance.secondbox.Add(box); + } + } + } + } + else if (carequipment.CarState_CarPlt == "1") + { + Debug.Log("小车身上没有箱子"); + if (car.gameObject.transform.childCount > 0) + { + GameObject box = car.gameObject.transform.GetChild(0).gameObject; + box.gameObject.transform.DOMoveY(box.gameObject.transform.position.y + 0.2f, 0.4f).SetEase(Ease.InOutQuad).OnComplete(() => + { + if (box.GetComponent()) + { + Collider collider = box.GetComponent(); + if (collider) + { + collider.enabled = false; + Debug.Log("失活了箱子触发器"); + box.gameObject.transform.SetParent(null); + Debug.Log("把箱子父物体取消"); + } + Debug.Log("卸箱动画向上提"); + box.gameObject.transform.DOMoveY(box.gameObject.transform.position.y - 0.62f, 1f).SetEase(Ease.InOutQuad).OnComplete(() => + { + Debug.Log("卸箱动画向下提"); + }); + } + }); + } + } + //else + //{ + // BoxCollider cars = car.GetComponent(); + //} + //car.transform.DOMove(displacement.transform.position, Vector3.Distance(car.transform.position, displacement.transform.position) / speed).SetEase(Ease.InOutQuad); + + } + } + /// + /// 第五个小车 + /// + /// + /// + int index5 = 1; + public void Carpoint5(GameObject car, Carequipment carequipment) + { + Debug.Log(carequipment.id); + if (car) + { + Carinformation carbox = car.GetComponent(); + carbox.BoxCode = carequipment.CarState_BoxCode; + string point = carequipment.CarState_Car_Row + "-" + carequipment.CarState_Car_Column + "-" + carequipment.CarState_Car_Layer; + Debug.Log("打印小车点位" + point); + if (GameObject.Find(point)) + { + GameObject displacement = GameObject.Find(point); + if (displacement != null && index5 < 2) + { + car.transform.position = displacement.transform.position; + index5++; + } + else if (displacement != null) + { + Debug.Log(index5); + Designateddisplacement(car, displacement.transform.position, speed); + Debug.Log("小车位移到指定点位"); + } + } + if (carequipment.CarState_CarPlt == "2") + { + if (car.gameObject.transform.childCount == 0 && carequipment.CarState_BoxCode != "0") + { + if (BoxID) + { + GameObject box = Instantiate(BoxID, car.gameObject.transform); + Boxinformation boxinformation = box.AddComponent(); + boxinformation.ID = carequipment.CarState_BoxCode; + Debug.Log("小车身上没有箱子,克隆出来一个箱子" + carequipment.CarState_BoxCode); + if (box.gameObject != null) + { + // 获取触发器物体的碰撞体 + Collider triggerCollider = car.GetComponent(); + + // 确保触发器物体有碰撞体 + if (triggerCollider != null) + { + // 计算触发器物体顶部的世界坐标 + Vector3 triggerPosition = triggerCollider.bounds.center; + Vector3 triggerTop = triggerPosition + Vector3.up * (triggerCollider.bounds.extents.y); + + // 设置物体的位置 + box.gameObject.transform.localEulerAngles = new Vector3(90, 0, 0); + box.gameObject.transform.position = triggerTop; + box.gameObject.transform.SetParent(car.gameObject.transform, false); + + Debug.Log("箱子位置初始化"); + } + else + { + Debug.LogError("触发器没有碰撞体"); + } + } + if (carequipment.CarState_Car_Layer.Equals(1)) + { + GameObject childbox = box.transform.GetChild(0).gameObject; + MqttManager.Instance.firstbox.Add(childbox); + MqttManager.Instance.firstbox.Add(box); + } + else + { + GameObject childbox = box.transform.GetChild(0).gameObject; + MqttManager.Instance.secondbox.Add(childbox); + MqttManager.Instance.secondbox.Add(box); + } + } + } + } + else if (carequipment.CarState_CarPlt == "1") + { + Debug.Log("小车身上没有箱子"); + if (car.gameObject.transform.childCount > 0) + { + GameObject box = car.gameObject.transform.GetChild(0).gameObject; + box.gameObject.transform.DOMoveY(box.gameObject.transform.position.y + 0.2f, 0.4f).SetEase(Ease.InOutQuad).OnComplete(() => + { + if (box.GetComponent()) + { + Collider collider = box.GetComponent(); + if (collider) + { + collider.enabled = false; + Debug.Log("失活了箱子触发器"); + box.gameObject.transform.SetParent(null); + Debug.Log("把箱子父物体取消"); + } + Debug.Log("卸箱动画向上提"); + box.gameObject.transform.DOMoveY(box.gameObject.transform.position.y - 0.62f, 1f).SetEase(Ease.InOutQuad).OnComplete(() => + { + Debug.Log("卸箱动画向下提"); + }); + } + }); + } + } + //else + //{ + // BoxCollider cars = car.GetComponent(); + //} + //car.transform.DOMove(displacement.transform.position, Vector3.Distance(car.transform.position, displacement.transform.position) / speed).SetEase(Ease.InOutQuad); + + } + } + /// + /// 第六个小车 + /// + /// + /// + int index6 = 1; + public void Carpoint6(GameObject car, Carequipment carequipment) + { + Debug.Log(carequipment.id); + if (car) + { + Carinformation carbox = car.GetComponent(); + carbox.BoxCode = carequipment.CarState_BoxCode; + string point = carequipment.CarState_Car_Row + "-" + carequipment.CarState_Car_Column + "-" + carequipment.CarState_Car_Layer; + Debug.Log("打印小车点位" + point); + if (GameObject.Find(point)) + { + GameObject displacement = GameObject.Find(point); + if (displacement != null && index6 < 2) + { + car.transform.position = displacement.transform.position; + index6++; + } + else if (displacement != null) + { + Debug.Log(index6); + Designateddisplacement(car, displacement.transform.position, speed); + Debug.Log("小车位移到指定点位"); + } + } + if (carequipment.CarState_CarPlt == "2") + { + if (car.gameObject.transform.childCount == 0 && carequipment.CarState_BoxCode != "0") + { + if (BoxID) + { + GameObject box = Instantiate(BoxID, car.gameObject.transform); + Boxinformation boxinformation = box.AddComponent(); + boxinformation.ID = carequipment.CarState_BoxCode; + Debug.Log("小车身上没有箱子,克隆出来一个箱子" + carequipment.CarState_BoxCode); + if (box.gameObject != null) + { + // 获取触发器物体的碰撞体 + Collider triggerCollider = car.GetComponent(); + + // 确保触发器物体有碰撞体 + if (triggerCollider != null) + { + // 计算触发器物体顶部的世界坐标 + Vector3 triggerPosition = triggerCollider.bounds.center; + Vector3 triggerTop = triggerPosition + Vector3.up * (triggerCollider.bounds.extents.y); + + // 设置物体的位置 + box.gameObject.transform.localEulerAngles = new Vector3(90, 0, 0); + box.gameObject.transform.position = triggerTop; + box.gameObject.transform.SetParent(car.gameObject.transform, false); + + Debug.Log("箱子位置初始化"); + } + else + { + Debug.LogError("触发器没有碰撞体"); + } + } + if (carequipment.CarState_Car_Layer.Equals(1)) + { + GameObject childbox = box.transform.GetChild(0).gameObject; + MqttManager.Instance.firstbox.Add(childbox); + MqttManager.Instance.firstbox.Add(box); + } + else + { + GameObject childbox = box.transform.GetChild(0).gameObject; + MqttManager.Instance.secondbox.Add(childbox); + MqttManager.Instance.secondbox.Add(box); + } + } + } + } + else if (carequipment.CarState_CarPlt == "1") + { + Debug.Log("小车身上没有箱子"); + if (car.gameObject.transform.childCount > 0) + { + GameObject box = car.gameObject.transform.GetChild(0).gameObject; + box.gameObject.transform.DOMoveY(box.gameObject.transform.position.y + 0.2f, 0.4f).SetEase(Ease.InOutQuad).OnComplete(() => + { + if (box.GetComponent()) + { + Collider collider = box.GetComponent(); + if (collider) + { + collider.enabled = false; + Debug.Log("失活了箱子触发器"); + box.gameObject.transform.SetParent(null); + Debug.Log("把箱子父物体取消"); + } + Debug.Log("卸箱动画向上提"); + box.gameObject.transform.DOMoveY(box.gameObject.transform.position.y - 0.62f, 1f).SetEase(Ease.InOutQuad).OnComplete(() => + { + Debug.Log("卸箱动画向下提"); + }); + } + }); + } + } + //else + //{ + // BoxCollider cars = car.GetComponent(); + //} + //car.transform.DOMove(displacement.transform.position, Vector3.Distance(car.transform.position, displacement.transform.position) / speed).SetEase(Ease.InOutQuad); + + } + } + /// + /// 第七个小车 + /// + /// + /// + int index7 = 1; + public void Carpoint7(GameObject car, Carequipment carequipment) + { + Debug.Log(carequipment.id); + if (car) + { + Carinformation carbox = car.GetComponent(); + carbox.BoxCode = carequipment.CarState_BoxCode; + string point = carequipment.CarState_Car_Row + "-" + carequipment.CarState_Car_Column + "-" + carequipment.CarState_Car_Layer; + Debug.Log("打印小车点位" + point); + if (GameObject.Find(point)) + { + GameObject displacement = GameObject.Find(point); + if (displacement != null && index7 < 2) + { + car.transform.position = displacement.transform.position; + index7++; + } + else if (displacement != null) + { + Debug.Log(index7); + Designateddisplacement(car, displacement.transform.position, speed); + Debug.Log("小车位移到指定点位"); + } + } + if (carequipment.CarState_CarPlt == "2") + { + if (car.gameObject.transform.childCount == 0 && carequipment.CarState_BoxCode != "0") + { + if (BoxID) + { + GameObject box = Instantiate(BoxID, car.gameObject.transform); + Boxinformation boxinformation = box.AddComponent(); + boxinformation.ID = carequipment.CarState_BoxCode; + Debug.Log("小车身上没有箱子,克隆出来一个箱子" + carequipment.CarState_BoxCode); + if (box.gameObject != null) + { + // 获取触发器物体的碰撞体 + Collider triggerCollider = car.GetComponent(); + + // 确保触发器物体有碰撞体 + if (triggerCollider != null) + { + // 计算触发器物体顶部的世界坐标 + Vector3 triggerPosition = triggerCollider.bounds.center; + Vector3 triggerTop = triggerPosition + Vector3.up * (triggerCollider.bounds.extents.y); + + // 设置物体的位置 + box.gameObject.transform.localEulerAngles = new Vector3(90, 0, 0); + box.gameObject.transform.position = triggerTop; + box.gameObject.transform.SetParent(car.gameObject.transform, false); + + Debug.Log("箱子位置初始化"); + } + else + { + Debug.LogError("触发器没有碰撞体"); + } + } + if (carequipment.CarState_Car_Layer.Equals(1)) + { + GameObject childbox = box.transform.GetChild(0).gameObject; + MqttManager.Instance.firstbox.Add(childbox); + MqttManager.Instance.firstbox.Add(box); + } + else + { + GameObject childbox = box.transform.GetChild(0).gameObject; + MqttManager.Instance.secondbox.Add(childbox); + MqttManager.Instance.secondbox.Add(box); + } + } + } + } + else if (carequipment.CarState_CarPlt == "1") + { + Debug.Log("小车身上没有箱子"); + if (car.gameObject.transform.childCount > 0) + { + GameObject box = car.gameObject.transform.GetChild(0).gameObject; + box.gameObject.transform.DOMoveY(box.gameObject.transform.position.y + 0.2f, 0.4f).SetEase(Ease.InOutQuad).OnComplete(() => + { + if (box.GetComponent()) + { + Collider collider = box.GetComponent(); + if (collider) + { + collider.enabled = false; + Debug.Log("失活了箱子触发器"); + box.gameObject.transform.SetParent(null); + Debug.Log("把箱子父物体取消"); + } + Debug.Log("卸箱动画向上提"); + box.gameObject.transform.DOMoveY(box.gameObject.transform.position.y - 0.62f, 1f).SetEase(Ease.InOutQuad).OnComplete(() => + { + Debug.Log("卸箱动画向下提"); + }); + } + }); + } + } + //else + //{ + // BoxCollider cars = car.GetComponent(); + //} + //car.transform.DOMove(displacement.transform.position, Vector3.Distance(car.transform.position, displacement.transform.position) / speed).SetEase(Ease.InOutQuad); + + } + } + /// + /// 第八个小车 + /// + /// + /// + int index8 = 1; + public void Carpoint8(GameObject car, Carequipment carequipment) + { + Debug.Log(carequipment.id); + if (car) + { + Carinformation carbox = car.GetComponent(); + carbox.BoxCode = carequipment.CarState_BoxCode; + string point = carequipment.CarState_Car_Row + "-" + carequipment.CarState_Car_Column + "-" + carequipment.CarState_Car_Layer; + Debug.Log("打印小车点位" + point); + if (GameObject.Find(point)) + { + GameObject displacement = GameObject.Find(point); + if (displacement != null && index8 < 2) + { + car.transform.position = displacement.transform.position; + index8++; + } + else if (displacement != null) + { + Debug.Log(index8); + Designateddisplacement(car, displacement.transform.position, speed); + Debug.Log("小车位移到指定点位"); + } + } + if (carequipment.CarState_CarPlt == "2") + { + if (car.gameObject.transform.childCount == 0 && carequipment.CarState_BoxCode != "0") + { + if (BoxID) + { + GameObject box = Instantiate(BoxID, car.gameObject.transform); + Boxinformation boxinformation = box.AddComponent(); + boxinformation.ID = carequipment.CarState_BoxCode; + Debug.Log("小车身上没有箱子,克隆出来一个箱子" + carequipment.CarState_BoxCode); + if (box.gameObject != null) + { + // 获取触发器物体的碰撞体 + Collider triggerCollider = car.GetComponent(); + + // 确保触发器物体有碰撞体 + if (triggerCollider != null) + { + // 计算触发器物体顶部的世界坐标 + Vector3 triggerPosition = triggerCollider.bounds.center; + Vector3 triggerTop = triggerPosition + Vector3.up * (triggerCollider.bounds.extents.y); + + // 设置物体的位置 + box.gameObject.transform.localEulerAngles = new Vector3(90, 0, 0); + box.gameObject.transform.position = triggerTop; + box.gameObject.transform.SetParent(car.gameObject.transform, false); + + Debug.Log("箱子位置初始化"); + } + else + { + Debug.LogError("触发器没有碰撞体"); + } + } + if (carequipment.CarState_Car_Layer.Equals(1)) + { + GameObject childbox = box.transform.GetChild(0).gameObject; + MqttManager.Instance.firstbox.Add(childbox); + MqttManager.Instance.firstbox.Add(box); + } + else + { + GameObject childbox = box.transform.GetChild(0).gameObject; + MqttManager.Instance.secondbox.Add(childbox); + MqttManager.Instance.secondbox.Add(box); + } + } + } + } + else if (carequipment.CarState_CarPlt == "1") + { + Debug.Log("小车身上没有箱子"); + if (car.gameObject.transform.childCount > 0) + { + GameObject box = car.gameObject.transform.GetChild(0).gameObject; + box.gameObject.transform.DOMoveY(box.gameObject.transform.position.y + 0.2f, 0.4f).SetEase(Ease.InOutQuad).OnComplete(() => + { + if (box.GetComponent()) + { + Collider collider = box.GetComponent(); + if (collider) + { + collider.enabled = false; + Debug.Log("失活了箱子触发器"); + box.gameObject.transform.SetParent(null); + Debug.Log("把箱子父物体取消"); + } + Debug.Log("卸箱动画向上提"); + box.gameObject.transform.DOMoveY(box.gameObject.transform.position.y - 0.62f, 1f).SetEase(Ease.InOutQuad).OnComplete(() => + { + Debug.Log("卸箱动画向下提"); + }); + } + }); + } + } + //else + //{ + // BoxCollider cars = car.GetComponent(); + //} + //car.transform.DOMove(displacement.transform.position, Vector3.Distance(car.transform.position, displacement.transform.position) / speed).SetEase(Ease.InOutQuad); + } } /// @@ -199,6 +1180,7 @@ public class MqttManager : MonoSingleton /// 位移的速度 public void Designateddisplacement(GameObject car, Vector3 dis, float speed) { + Debug.Log("小车运动了"); float times = Vector3.Distance(car.transform.position, dis) / speed; car.transform.DOMove(dis, times).SetEase(Ease.InOutQuad); } diff --git a/Assets/Scripts/YL/CS.cs b/Assets/Scripts/YL/CS.cs new file mode 100644 index 0000000..7c6a82b --- /dev/null +++ b/Assets/Scripts/YL/CS.cs @@ -0,0 +1,22 @@ +using DefaultNamespace; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class CS : MonoBehaviour +{ + // Start is called before the first frame update + public GameObject BoxID; + void Start() + { + GameObject box = Instantiate(BoxID); + box.transform.SetParent(transform,false); + box.transform.localEulerAngles = new Vector3(90,0,0); + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/Assets/Scripts/YL/CS.cs.meta b/Assets/Scripts/YL/CS.cs.meta new file mode 100644 index 0000000..05880e6 --- /dev/null +++ b/Assets/Scripts/YL/CS.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ee73452f827878643bd0a9da60c9d500 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/YL/Detection.cs b/Assets/Scripts/YL/Detection.cs new file mode 100644 index 0000000..03cb44f --- /dev/null +++ b/Assets/Scripts/YL/Detection.cs @@ -0,0 +1,72 @@ +using DG.Tweening; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UIElements; + +public class Detection : MonoBehaviour +{ + private Collider triggerCollider; + + private void Start() + { + triggerCollider = GetComponent(); + if (triggerCollider == null) + { + Debug.LogError("ûҵײ壡"); + return; + } + } + + private void Update() + { + // 鴥Ƿ񱻽 + if (!triggerCollider.enabled) + { + // ʧЭ + StartCoroutine(ActivateAfterDelay(15f)); + } + //if (Input.GetMouseButtonDown(2)) + //{ + // transform.DOMoveY(transform.position.y + 0.4f, 1f).SetEase(Ease.InOutQuad).OnComplete(() => + // { + // Collider collider = GetComponent(); + // if (collider) + // { + // collider.enabled = false; + // Debug.Log("ʧӴ"); + // transform.SetParent(null); + // } + // Debug.Log("ж䶯"); + // transform.DOMoveY(transform.position.y - 0.4f, 1f).SetEase(Ease.InOutQuad).OnComplete(() => + // { + // Debug.Log("ж䶯"); + // }); + // }); + //} + } + + private IEnumerator ActivateAfterDelay(float delay) + { + // ȴָʱ + yield return new WaitForSeconds(delay); + + //  + triggerCollider.enabled = true; + //Debug.Log("Ѽ"); + + // ⴥ״̬ + while (true) + { + // ǷȻ + if (!triggerCollider.enabled) + { + //Debug.Log("ٴεʮٵ"); + // ٴʧЭ + StartCoroutine(ActivateAfterDelay(15f)); + yield break; // ˳ǰЭ + } + yield return null; // ȴһ֡ + } + } +} diff --git a/Assets/Scripts/YL/Detection.cs.meta b/Assets/Scripts/YL/Detection.cs.meta new file mode 100644 index 0000000..b3297d1 --- /dev/null +++ b/Assets/Scripts/YL/Detection.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ef5411e111cb04441a761bc6cf9a1fc6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/YL/Fetchbox.cs b/Assets/Scripts/YL/Fetchbox.cs index 9b96602..7760b97 100644 --- a/Assets/Scripts/YL/Fetchbox.cs +++ b/Assets/Scripts/YL/Fetchbox.cs @@ -71,6 +71,7 @@ public class Fetchbox : MonoBehaviour boxinformation.palletNum = shelfBoxModel.result[i].palletNum; boxinformation.itemType = shelfBoxModel.result[i].itemType; boxinformation.isSpecial = shelfBoxModel.result[i].isSpecial; + //if (shelfBoxModel.result[i]. boxinformationList.Add(boxinformation); if (shelfBoxModel.result[i].layer.Equals(1)) { diff --git a/Assets/Scripts/YL/Interaction.cs b/Assets/Scripts/YL/Interaction.cs index 329471a..6aeab1c 100644 --- a/Assets/Scripts/YL/Interaction.cs +++ b/Assets/Scripts/YL/Interaction.cs @@ -4,7 +4,6 @@ using System; using UnityEngine; using UnityEngine.UI; using static InterfaceManager; -using static UnityEditor.Timeline.Actions.MenuPriority; /// /// жӵ״̬ /// @@ -141,12 +140,13 @@ public class Interaction : MonoBehaviour if (hit.collider.gameObject.GetComponent()) { Boxinformation boxinformation = hit.collider.gameObject.GetComponent(); - if (boxinformation.itemType == "EmptyBox") - { - UIBoxdatapanel.Emptydata(""); - } + //if (boxinformation.itemType == "EmptyBox") + //{ + // UIBoxdatapanel.Emptydata(""); + //} //Debug.Log(boxinformation.locationId); string url = Boxinformationface + boxinformation.locationId; + Debug.Log(url); StartCoroutine(Post1(url, (data) => { Debug.Log(data); @@ -154,11 +154,11 @@ public class Interaction : MonoBehaviour // Debug.Log(cigaretteinformation.time); for (int i = 0; i < cigaretteinformation.result.Count; i++) { - if (cigaretteinformation.result[i].lineNum.Equals(10)) + if (cigaretteinformation.result[i].lineNum.Equals(1)) { UIBoxdatapanel.Getdata(cigaretteinformation.result[i].itemDesc, cigaretteinformation.result[i].batch, cigaretteinformation.result[i].palletNum, cigaretteinformation.result[i].weight); }; - if (cigaretteinformation.result[i].lineNum.Equals(20)) + if (cigaretteinformation.result[i].lineNum.Equals(2)) { UIBoxdatapanel.GetDragdown(cigaretteinformation.result[i].palletNum, cigaretteinformation.result[i].weight); } diff --git a/Assets/Scripts/YL/Loadingoperation.cs b/Assets/Scripts/YL/Loadingoperation.cs index 7869fd1..8e76cc2 100644 --- a/Assets/Scripts/YL/Loadingoperation.cs +++ b/Assets/Scripts/YL/Loadingoperation.cs @@ -2,6 +2,7 @@ using DG.Tweening; using System.Collections; using System.Collections.Generic; using UnityEngine; +using UnityEngine.UIElements; public class Loadingoperation : MonoBehaviour { @@ -14,38 +15,45 @@ public class Loadingoperation : MonoBehaviour if (other.gameObject.CompareTag("Box")) { - Carinformation car = transform.GetComponent(); - Boxinformation boxinformation = other.gameObject.transform.GetComponent(); - if (car && boxinformation) + Debug.Log(""); + if (transform.childCount == 0) { - boxinformation.ID = car.BoxCode; - } - float pos = other.transform.position.y + 0.3f; - other.transform.DOMoveY(pos, 0.3f).SetEase(Ease.InOutQuad); - other.transform.SetParent(transform); - if (other.gameObject != null) - { - // ȡײ - Collider triggerCollider = GetComponent(); - - // ȷײ - if (triggerCollider != null) + Carinformation car = transform.GetComponent(); + Boxinformation boxinformation = other.gameObject.transform.GetComponent(); + //if (car && boxinformation) + //{ + // boxinformation.ID = car.BoxCode; + //} + //float pos = other.transform.position.y + 0.5f; + other.transform.DOMoveY(other.transform.position.y + 0.42f, 0.3f).SetEase(Ease.InOutQuad).OnComplete(() => { - // 㴥嶥 - Vector3 triggerPosition = triggerCollider.bounds.center; - Vector3 triggerTop = triggerPosition + Vector3.up * (triggerCollider.bounds.extents.y + -0.2f); + if (other.gameObject != null) + { + // ȡײ + Collider triggerCollider = GetComponent(); - // λ - other.transform.position = triggerTop; - } - else - { - Debug.LogError("ûײ"); - } - } - else - { - Debug.LogError("ûлȡ"); + // ȷײ + if (triggerCollider != null) + { + // 㴥嶥 + Vector3 triggerPosition = triggerCollider.bounds.center; + Vector3 triggerTop = triggerPosition + Vector3.up * (triggerCollider.bounds.extents.y); + + // λ + + other.transform.position = triggerTop; + other.gameObject.transform.SetParent(transform); + } + else + { + Debug.LogError("ûײ"); + } + } + else + { + Debug.LogError("ûлȡ"); + } + }); } } }