From 840e0cd26e263faf83b00001938536c45a80e50c Mon Sep 17 00:00:00 2001 From: huyulong <1838407198@qq.com> Date: Wed, 18 Dec 2024 16:35:39 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=B8=E6=9C=BA=E6=8E=A7=E5=88=B6=E6=97=8B?= =?UTF-8?q?=E8=BD=AC=E5=8A=A8=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xiaofang/Assets/Scenes/Tmap 1.unity | 316 +++++++++++------- .../Script/hylScripts/CameraSmoothMove.cs | 139 +++++++- 2 files changed, 312 insertions(+), 143 deletions(-) diff --git a/xiaofang/Assets/Scenes/Tmap 1.unity b/xiaofang/Assets/Scenes/Tmap 1.unity index 0f56b2ea..7f6e594e 100644 --- a/xiaofang/Assets/Scenes/Tmap 1.unity +++ b/xiaofang/Assets/Scenes/Tmap 1.unity @@ -298,52 +298,6 @@ MeshFilter: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 19367787} m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} ---- !u!1 &23984260 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 23984262} - - component: {fileID: 23984261} - m_Layer: 0 - m_Name: BurstCollisionWorld - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &23984261 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 23984260} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: f1a161c4294214a4fbcb7e9e94800494, type: 3} - m_Name: - m_EditorClassIdentifier: - cellSpans: - m_AlignBytes: 16 ---- !u!4 &23984262 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 23984260} - 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_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 36 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &24462543 PrefabInstance: m_ObjectHideFlags: 0 @@ -4164,7 +4118,7 @@ PrefabInstance: m_Modifications: - target: {fileID: -8679921383154817045, guid: 0c9b084f2070bda45b87da961d2eb0f6, type: 3} propertyPath: m_RootOrder - value: 9 + value: 10 objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: 0c9b084f2070bda45b87da961d2eb0f6, type: 3} propertyPath: m_LocalPosition.x @@ -4922,7 +4876,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 22 + m_RootOrder: 23 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &159663861 PrefabInstance: @@ -6234,7 +6188,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 15 + m_RootOrder: 16 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!64 &339719735 MeshCollider: @@ -6734,7 +6688,7 @@ Transform: - {fileID: 272025130} - {fileID: 1600741273} m_Father: {fileID: 0} - m_RootOrder: 31 + m_RootOrder: 32 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!65 &382802813 BoxCollider: @@ -7219,7 +7173,7 @@ PrefabInstance: m_Modifications: - target: {fileID: -8679921383154817045, guid: 25528d3d2120cee47bccf93decd4fbdf, type: 3} propertyPath: m_RootOrder - value: 3 + value: 4 objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: 25528d3d2120cee47bccf93decd4fbdf, type: 3} propertyPath: m_LocalPosition.x @@ -8123,7 +8077,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 28 + m_RootOrder: 29 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &479940076 MonoBehaviour: @@ -8253,7 +8207,7 @@ PrefabInstance: m_Modifications: - target: {fileID: -8679921383154817045, guid: 454dc3d5cb346c148b640203a8bc1174, type: 3} propertyPath: m_RootOrder - value: 2 + value: 3 objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: 454dc3d5cb346c148b640203a8bc1174, type: 3} propertyPath: m_LocalScale.x @@ -8419,7 +8373,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 17 + m_RootOrder: 18 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &542563896 GameObject: @@ -8914,7 +8868,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 21 + m_RootOrder: 22 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &583497863 PrefabInstance: @@ -9657,7 +9611,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 25 + m_RootOrder: 26 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &673038100 PrefabInstance: @@ -9880,7 +9834,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 33 + m_RootOrder: 34 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &702577176 MonoBehaviour: @@ -10103,7 +10057,7 @@ Transform: - {fileID: 1973166535} - {fileID: 1629676686} m_Father: {fileID: 0} - m_RootOrder: 12 + m_RootOrder: 13 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!64 &713484458 MeshCollider: @@ -10371,7 +10325,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 7104765112034956015, guid: 6815aad4cd6cb734a9d63a7210677333, type: 3} propertyPath: m_RootOrder - value: 16 + value: 17 objectReference: {fileID: 0} - target: {fileID: 7104765112034956015, guid: 6815aad4cd6cb734a9d63a7210677333, type: 3} propertyPath: m_LocalPosition.x @@ -11005,7 +10959,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 27 + m_RootOrder: 28 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &810501282 MonoBehaviour: @@ -11371,7 +11325,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 13 + m_RootOrder: 14 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &858128596 stripped GameObject: @@ -12477,7 +12431,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 11 + m_RootOrder: 12 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &984914341 PrefabInstance: @@ -12585,7 +12539,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 19 + m_RootOrder: 20 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &996888830 MonoBehaviour: @@ -12971,7 +12925,7 @@ RectTransform: - {fileID: 1081784991} - {fileID: 1359335859} m_Father: {fileID: 0} - m_RootOrder: 14 + m_RootOrder: 15 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -14265,52 +14219,6 @@ Transform: m_CorrespondingSourceObject: {fileID: 454008, guid: c9aa675884b75594b9a1c43c5c4e5c7a, type: 3} m_PrefabInstance: {fileID: 1108412769} m_PrefabAsset: {fileID: 0} ---- !u!1 &1108700887 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1108700889} - - component: {fileID: 1108700888} - m_Layer: 0 - m_Name: BurstCollisionWorld - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &1108700888 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1108700887} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: f1a161c4294214a4fbcb7e9e94800494, type: 3} - m_Name: - m_EditorClassIdentifier: - cellSpans: - m_AlignBytes: 16 ---- !u!4 &1108700889 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1108700887} - 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_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 36 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &1111438060 PrefabInstance: m_ObjectHideFlags: 0 @@ -20783,7 +20691,7 @@ Transform: m_ConstrainProportionsScale: 1 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 32 + m_RootOrder: 33 m_LocalEulerAnglesHint: {x: -90, y: 0, z: 0} --- !u!64 &1263546210 MeshCollider: @@ -21103,7 +21011,7 @@ Transform: - {fileID: 496425325} - {fileID: 1670656697} m_Father: {fileID: 0} - m_RootOrder: 34 + m_RootOrder: 35 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!64 &1300490224 MeshCollider: @@ -22791,7 +22699,7 @@ Transform: - {fileID: 1882199187} - {fileID: 119116319} m_Father: {fileID: 0} - m_RootOrder: 29 + m_RootOrder: 30 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!64 &1453694928 MeshCollider: @@ -24036,7 +23944,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 26 + m_RootOrder: 27 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &1480398099 PrefabInstance: @@ -24137,7 +24045,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 24 + m_RootOrder: 25 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &1481704192 PrefabInstance: @@ -24795,7 +24703,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 7 + m_RootOrder: 8 m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} --- !u!1001 &1517804048 PrefabInstance: @@ -24905,7 +24813,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 30 + m_RootOrder: 31 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &1526740603 MonoBehaviour: @@ -24944,8 +24852,8 @@ MonoBehaviour: LanguageJsonFile: {fileID: 4900000, guid: 62a41129c4663ee41a06274114d28feb, type: 3} SelectJsonFile: {fileID: 4900000, guid: 3efd15f4195557144a45659d2baa1ba3, type: 3} TaskJsonFile: {fileID: 4900000, guid: 4dec25769ed4ed3469693b1c881248af, type: 3} - GlobalJsonFile: {fileID: 0} - SelectsJsonFile: {fileID: 0} + GlobalJsonFile: {fileID: 4900000, guid: 27ecc4e37cb448e45a2611c086cdfb90, type: 3} + SelectsJsonFile: {fileID: 4900000, guid: 3efd15f4195557144a45659d2baa1ba3, type: 3} --- !u!1001 &1542437476 PrefabInstance: m_ObjectHideFlags: 0 @@ -25093,7 +25001,7 @@ PrefabInstance: m_Modifications: - target: {fileID: -8679921383154817045, guid: 66a5dd237d335854380f51c11f41d9a8, type: 3} propertyPath: m_RootOrder - value: 1 + value: 2 objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: 66a5dd237d335854380f51c11f41d9a8, type: 3} propertyPath: m_LocalPosition.x @@ -26675,6 +26583,110 @@ Transform: m_CorrespondingSourceObject: {fileID: 443876, guid: be8a9b4fd6545dd4e901964c42af5f6c, type: 3} m_PrefabInstance: {fileID: 1700457050} m_PrefabAsset: {fileID: 0} +--- !u!1 &1707678916 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1707678919} + - component: {fileID: 1707678920} + - component: {fileID: 1707678918} + - component: {fileID: 1707678917} + m_Layer: 0 + m_Name: Camera + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &1707678917 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1707678916} + m_Enabled: 1 +--- !u!20 &1707678918 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1707678916} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &1707678919 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1707678916} + m_LocalRotation: {x: -0, y: 0.98063743, z: -0, w: 0.1958323} + m_LocalPosition: {x: -2.15, y: 11.89, z: 40.53} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 157.413, z: 0} +--- !u!114 &1707678920 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1707678916} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 276124c99c246e840b4970f38c67029e, type: 3} + m_Name: + m_EditorClassIdentifier: + target: {fileID: 88965377508065921} + offset: {x: 0, y: 8, z: -1} + orbitSpeed: 2 + smoothSpeed: 0.125 + minDistance: 80 + maxDistance: 80 + scrollSpeed: 2 --- !u!1001 &1709243970 PrefabInstance: m_ObjectHideFlags: 0 @@ -27980,6 +27992,52 @@ MeshCollider: m_Convex: 0 m_CookingOptions: 30 m_Mesh: {fileID: -7353403159277181372, guid: 00003e04dc9a2534eb207f108c7b0cd3, type: 3} +--- !u!1 &1821068508 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1821068510} + - component: {fileID: 1821068509} + m_Layer: 0 + m_Name: BurstCollisionWorld + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1821068509 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1821068508} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f1a161c4294214a4fbcb7e9e94800494, type: 3} + m_Name: + m_EditorClassIdentifier: + cellSpans: + m_AlignBytes: 16 +--- !u!4 &1821068510 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1821068508} + 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_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 38 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &1822675538 PrefabInstance: m_ObjectHideFlags: 0 @@ -28424,7 +28482,7 @@ PrefabInstance: m_Modifications: - target: {fileID: -8679921383154817045, guid: 53b3ada11775bfd4282e07e6e63c968f, type: 3} propertyPath: m_RootOrder - value: 5 + value: 6 objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: 53b3ada11775bfd4282e07e6e63c968f, type: 3} propertyPath: m_LocalPosition.x @@ -28961,7 +29019,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 23 + m_RootOrder: 24 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &1912789160 PrefabInstance: @@ -29716,7 +29774,7 @@ PrefabInstance: m_Modifications: - target: {fileID: -8679921383154817045, guid: 69a55f19217e42746bdaf0c10a7cbc80, type: 3} propertyPath: m_RootOrder - value: 4 + value: 5 objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: 69a55f19217e42746bdaf0c10a7cbc80, type: 3} propertyPath: m_LocalPosition.x @@ -30332,7 +30390,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 20 + m_RootOrder: 21 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!64 &2069562217 MeshCollider: @@ -31366,7 +31424,7 @@ Transform: - {fileID: 2112013849} - {fileID: 125672022} m_Father: {fileID: 0} - m_RootOrder: 8 + m_RootOrder: 9 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!33 &119908498058829656 MeshFilter: @@ -31891,7 +31949,7 @@ Transform: - {fileID: 6100007915572801067} - {fileID: 2865482816726376136} m_Father: {fileID: 0} - m_RootOrder: 10 + m_RootOrder: 11 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!23 &555576767404427943 MeshRenderer: @@ -34132,7 +34190,7 @@ Transform: m_Children: - {fileID: 2057924365034160257} m_Father: {fileID: 0} - m_RootOrder: 35 + m_RootOrder: 36 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &2057924365745864529 MonoBehaviour: @@ -35441,7 +35499,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 2907630901887348954, guid: cb61a92f105ea18418e946bf54862340, type: 3} propertyPath: m_RootOrder - value: 18 + value: 19 objectReference: {fileID: 0} - target: {fileID: 2907630901887348954, guid: cb61a92f105ea18418e946bf54862340, type: 3} propertyPath: m_LocalPosition.x @@ -40135,7 +40193,7 @@ PrefabInstance: objectReference: {fileID: 1493242969} - target: {fileID: 8479287258615548071, guid: 4bc999dc543a61148a0ba3bb1dd45a4d, type: 3} propertyPath: m_RootOrder - value: 6 + value: 7 objectReference: {fileID: 0} - target: {fileID: 8479287258615548071, guid: 4bc999dc543a61148a0ba3bb1dd45a4d, type: 3} propertyPath: m_LocalPosition.x diff --git a/xiaofang/Assets/Script/hylScripts/CameraSmoothMove.cs b/xiaofang/Assets/Script/hylScripts/CameraSmoothMove.cs index db51e958..3e9f9ef0 100644 --- a/xiaofang/Assets/Script/hylScripts/CameraSmoothMove.cs +++ b/xiaofang/Assets/Script/hylScripts/CameraSmoothMove.cs @@ -1,29 +1,140 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; +using System.Threading.Tasks; public class CameraSmoothMove : MonoBehaviour { + public Transform target; // 相机围绕的目标(建筑物) + public Vector3 offset = new Vector3(0f, 2f, -5f); // 相机初始偏移量 + private float orbitSpeed = 0.5f; // 绕目标旋转的速度(度/秒) + public float smoothSpeed = 0.125f; // 平滑移动的速度 + public float minDistance = 2f; // 最小距离 + public float maxDistance = 15f; // 最大距离 + public float scrollSpeed = 2f; // 鼠标滚轮控制距离的速度 - public Transform startPoint; // 起始点 - public Transform endPoint; // 终点 - public float duration = 5f; // 移动所需的时间(秒) + private bool isOrbiting = true; // 是否正在绕建筑物旋转 + private float orbitDuration = 10f; // 绕建筑物转一圈所需的时间 + private Vector3 fixedPosition; // 相机停留的固定位置 + private Quaternion fixedRotation; // 相机停留时的旋转 + private float currentDistance; // 当前与目标的距离 + private Transform mainCameraTransform; // Main Camera 的位置和旋转 - private float elapsedTime = 0f; // 记录已经过去的时间 - - void Update() + private void Start() { - // 确保起始点和终点存在 - if (startPoint != null && endPoint != null) + if (target == null) { - // 更新经过的时间 - elapsedTime += Time.deltaTime; + Debug.LogError("目标建筑物未设置!"); + return; + } - // 计算摄像机的位置:根据时间比例计算当前位置 - float t = Mathf.Clamp01(elapsedTime / duration); + // 获取 Main Camera 的 Transform + mainCameraTransform = Camera.main.transform; - // 使用 Lerp 平滑过渡摄像机的位置 - transform.position = Vector3.Lerp(startPoint.position, endPoint.position, t); + // 设置初始距离 + currentDistance = -offset.z; + + // 计算旋转结束时相机应该停留的位置和旋转 + fixedPosition = mainCameraTransform.position; + fixedRotation = mainCameraTransform.rotation; + + if (isOrbiting) + { + StartOrbit(); } } + + private void Update() + { + // 响应鼠标滚轮输入,控制与目标的距离 + float scrollInput = Input.GetAxis("Mouse ScrollWheel"); + currentDistance -= scrollInput * scrollSpeed; // 增加或减少距离 + currentDistance = Mathf.Clamp(currentDistance, minDistance, maxDistance); + } + + // 启动围绕建筑物旋转 + public async void StartOrbit() + { + isOrbiting = true; + await OrbitAsync(); + StopOrbit(); + } + + // 停止围绕建筑物旋转,平滑过渡到 Main Camera 的位置和旋转 + public async void StopOrbit() + { + isOrbiting = false; + + // 获取 Main Camera 的最新位置和旋转 + fixedPosition = mainCameraTransform.position; + fixedRotation = mainCameraTransform.rotation; + + await MoveToFixedPositionAsync(); + } + + // 异步方法:通过 async 实现绕建筑物平滑旋转一圈 + private async Task OrbitAsync() + { + float elapsedTime = 0f; + + while (elapsedTime < orbitDuration) + { + if (!isOrbiting) break; // 提前退出 + + elapsedTime += Time.deltaTime; + + // 计算旋转角度 + float angle = Mathf.Lerp(0, 360f, elapsedTime / orbitDuration); + Vector3 offsetPosition = new Vector3( + Mathf.Cos(Mathf.Deg2Rad * angle) * currentDistance, + offset.y, + Mathf.Sin(Mathf.Deg2Rad * angle) * currentDistance + ); + + // 更新相机位置 + transform.position = target.position + offsetPosition; + transform.LookAt(target); // 保持相机面向目标 + + await Task.Yield(); // 等待下一帧 + } + } + + // 异步方法:平滑过渡到 Main Camera 的位置和旋转 + private async Task MoveToFixedPositionAsync() + { + float elapsedTime = 0f; + Vector3 startPosition = transform.position; + Quaternion startRotation = transform.rotation; + + while (elapsedTime < 1f) + { + elapsedTime += Time.deltaTime * smoothSpeed; + + // 平滑地插值相机位置和旋转 + transform.position = Vector3.Lerp(startPosition, fixedPosition, elapsedTime); + transform.rotation = Quaternion.Lerp(startRotation, fixedRotation, elapsedTime); + + await Task.Yield(); // 等待下一帧 + } + + // 确保最终位置和旋转与 Main Camera 对齐 + transform.position = fixedPosition; + transform.rotation = fixedRotation; + + // 隐藏相机 + HideCamera(); + } + + // 隐藏相机的方法 + private void HideCamera() + { + // 方法 1:禁用 Camera 组件 + GetComponent().enabled = false; + + // 方法 2:禁用整个 GameObject + // gameObject.SetActive(false); + + Debug.Log("相机已隐藏"); + } } +