总数显示修改,观察相机跟随路径

This commit is contained in:
2025-07-02 23:14:18 +08:00
parent 544d0171ce
commit 3fe3304e05
8 changed files with 553 additions and 290 deletions

View File

@ -45,7 +45,7 @@ Material:
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: e23351fad23d2f94ba8f7e9c088c0e1e, type: 3}
m_Texture: {fileID: 2800000, guid: 1cc148a6c8566704084ea3eeedc96652, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 MiB

After

Width:  |  Height:  |  Size: 1.3 MiB

View File

@ -255,7 +255,7 @@ Transform:
m_GameObject: {fileID: 14641664}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -2.37, y: 0, z: -6.626}
m_LocalPosition: {x: -2.55, y: 0, z: -7.31}
m_LocalScale: {x: 0.3, y: 0.3, z: 0.3}
m_ConstrainProportionsScale: 0
m_Children: []
@ -2723,7 +2723,7 @@ Transform:
m_GameObject: {fileID: 248679076}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 6.629, y: 0, z: -4.365}
m_LocalPosition: {x: 6.71, y: 0, z: -4.365}
m_LocalScale: {x: 0.3, y: 0.3, z: 0.3}
m_ConstrainProportionsScale: 0
m_Children: []
@ -3183,7 +3183,7 @@ Transform:
m_GameObject: {fileID: 282739198}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 1.877, y: 0, z: -1.648}
m_LocalPosition: {x: 2.28, y: 0, z: -1.648}
m_LocalScale: {x: 0.3, y: 0.3, z: 0.3}
m_ConstrainProportionsScale: 0
m_Children: []
@ -4237,7 +4237,7 @@ Transform:
m_GameObject: {fileID: 397196300}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 6.59, y: 0, z: -2.386}
m_LocalPosition: {x: 6.87, y: 0, z: -2.386}
m_LocalScale: {x: 0.3, y: 0.3, z: 0.3}
m_ConstrainProportionsScale: 0
m_Children: []
@ -4675,7 +4675,7 @@ Transform:
m_GameObject: {fileID: 444456008}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -4.94, y: 0, z: -5}
m_LocalPosition: {x: -5.05, y: 0, z: -5}
m_LocalScale: {x: 0.3, y: 0.3, z: 0.3}
m_ConstrainProportionsScale: 0
m_Children: []
@ -6911,7 +6911,7 @@ Transform:
m_GameObject: {fileID: 659130929}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -4.94, y: 0, z: -0.435}
m_LocalPosition: {x: -4.75, y: 0, z: -0.48}
m_LocalScale: {x: 0.3, y: 0.3, z: 0.3}
m_ConstrainProportionsScale: 0
m_Children: []
@ -7409,7 +7409,7 @@ Transform:
m_GameObject: {fileID: 718832131}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -4.87, y: 0, z: -6.566}
m_LocalPosition: {x: -5.05, y: 0, z: -7.29}
m_LocalScale: {x: 0.3, y: 0.3, z: 0.3}
m_ConstrainProportionsScale: 0
m_Children: []
@ -8073,7 +8073,7 @@ Transform:
m_GameObject: {fileID: 768846028}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -4.94, y: 0, z: -1.495}
m_LocalPosition: {x: -4.8, y: 0, z: -1.25}
m_LocalScale: {x: 0.3, y: 0.3, z: 0.3}
m_ConstrainProportionsScale: 0
m_Children: []
@ -8154,7 +8154,7 @@ Transform:
m_GameObject: {fileID: 788153996}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 8.5874815, y: -1.7436439, z: -115.075836}
m_LocalPosition: {x: 1.12, y: -1.7436439, z: -106.3}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
@ -8979,7 +8979,7 @@ Transform:
m_GameObject: {fileID: 908930056}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -2.381, y: 0, z: -3.85}
m_LocalPosition: {x: -2.22, y: 0, z: -3.85}
m_LocalScale: {x: 0.3, y: 0.3, z: 0.3}
m_ConstrainProportionsScale: 0
m_Children: []
@ -10184,13 +10184,13 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1047015106}
serializedVersion: 2
m_LocalRotation: {x: 0.3620372, y: -0.16267893, z: 0.05123903, w: 0.9164274}
m_LocalPosition: {x: 29.7, y: 44.4, z: -160.97583}
m_LocalRotation: {x: 0.54789597, y: 0.17021318, z: -0.11500217, w: 0.8109329}
m_LocalPosition: {x: -10.025402, y: 72.55203, z: -139.30481}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 42.862, y: -20.865, z: -1.867}
m_LocalEulerAnglesHint: {x: 45, y: 0, z: -20}
--- !u!1 &1047953458
GameObject:
m_ObjectHideFlags: 0
@ -10301,7 +10301,7 @@ Transform:
m_GameObject: {fileID: 1049644678}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 1.82, y: 0, z: -0.204}
m_LocalPosition: {x: 2.54, y: 0, z: -0.204}
m_LocalScale: {x: 0.3, y: 0.3, z: 0.3}
m_ConstrainProportionsScale: 0
m_Children: []
@ -11549,7 +11549,6 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
reflash: {fileID: 1174291869}
startFollowBtn: {fileID: 0}
compass: {fileID: 1119458015}
--- !u!114 &1132992220
MonoBehaviour:
@ -11605,7 +11604,7 @@ Transform:
m_GameObject: {fileID: 1151644926}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -5.151, y: 0, z: 4.097}
m_LocalPosition: {x: -4.48, y: 0, z: 4.64}
m_LocalScale: {x: 0.3, y: 0.3, z: 0.3}
m_ConstrainProportionsScale: 0
m_Children: []
@ -12238,7 +12237,7 @@ Transform:
m_GameObject: {fileID: 1193849249}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 1.947, y: 0, z: -3.38}
m_LocalPosition: {x: 2.15, y: 0, z: -3.38}
m_LocalScale: {x: 0.3, y: 0.3, z: 0.3}
m_ConstrainProportionsScale: 0
m_Children: []
@ -12404,7 +12403,7 @@ Transform:
m_GameObject: {fileID: 1198437231}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -2.42, y: 0, z: -0.226}
m_LocalPosition: {x: -2.42, y: 0, z: 0.16}
m_LocalScale: {x: 0.3, y: 0.3, z: 0.3}
m_ConstrainProportionsScale: 0
m_Children: []
@ -13786,7 +13785,7 @@ Transform:
m_GameObject: {fileID: 1286732492}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -4.94, y: 0, z: -3.84}
m_LocalPosition: {x: -5.03, y: 0, z: -3.84}
m_LocalScale: {x: 0.3, y: 0.3, z: 0.3}
m_ConstrainProportionsScale: 0
m_Children: []
@ -15084,13 +15083,13 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1462254335}
serializedVersion: 2
m_LocalRotation: {x: 0.3620372, y: -0.16267893, z: 0.05123903, w: 0.9164274}
m_LocalPosition: {x: 29.7, y: 44.4, z: -160.97583}
m_LocalRotation: {x: 0.16293223, y: 0.17022853, z: -0.09057178, w: 0.9676116}
m_LocalPosition: {x: -20.82, y: 31.46, z: -162.95}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 42.862, y: -20.865, z: -1.867}
m_LocalEulerAnglesHint: {x: 20.252, y: 18.643, z: -7.337}
--- !u!114 &1462254339
MonoBehaviour:
m_ObjectHideFlags: 0
@ -15120,6 +15119,7 @@ MonoBehaviour:
origanzoomMin: 4
HomePos: {fileID: 2024055160}
OtherPos: {fileID: 1309797243}
offect: -7
--- !u!1 &1466165897
GameObject:
m_ObjectHideFlags: 0
@ -15230,7 +15230,7 @@ Transform:
m_GameObject: {fileID: 1467457915}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -2.472, y: 0, z: 1.791}
m_LocalPosition: {x: -2.04, y: 0, z: 0.15}
m_LocalScale: {x: 0.3, y: 0.3, z: 0.3}
m_ConstrainProportionsScale: 0
m_Children: []
@ -16850,7 +16850,7 @@ Transform:
m_GameObject: {fileID: 1635935186}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 1.899, y: 0, z: -2.454}
m_LocalPosition: {x: 2.2, y: 0, z: -2.454}
m_LocalScale: {x: 0.3, y: 0.3, z: 0.3}
m_ConstrainProportionsScale: 0
m_Children: []
@ -17265,7 +17265,7 @@ Transform:
m_GameObject: {fileID: 1701121864}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 2.101, y: 0, z: -6.396}
m_LocalPosition: {x: 1.91, y: 0, z: -7.58}
m_LocalScale: {x: 0.3, y: 0.3, z: 0.3}
m_ConstrainProportionsScale: 0
m_Children: []
@ -17514,7 +17514,7 @@ Transform:
m_GameObject: {fileID: 1720414505}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -5.053, y: 0, z: 1.731}
m_LocalPosition: {x: -4.69, y: 0, z: 0.41}
m_LocalScale: {x: 0.3, y: 0.3, z: 0.3}
m_ConstrainProportionsScale: 0
m_Children: []
@ -18091,7 +18091,7 @@ Transform:
m_GameObject: {fileID: 1778153998}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -4.87, y: 0, z: -8.54}
m_LocalPosition: {x: -5.09, y: 0, z: -8.54}
m_LocalScale: {x: 0.3, y: 0.3, z: 0.3}
m_ConstrainProportionsScale: 0
m_Children: []
@ -18506,7 +18506,7 @@ Transform:
m_GameObject: {fileID: 1831718769}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -2.474, y: 0, z: 4.56}
m_LocalPosition: {x: -1.82, y: 0, z: 4.56}
m_LocalScale: {x: 0.3, y: 0.3, z: 0.3}
m_ConstrainProportionsScale: 0
m_Children: []
@ -18804,7 +18804,7 @@ Transform:
m_GameObject: {fileID: 1849144307}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -4.87, y: 0, z: -9.831}
m_LocalPosition: {x: -5.1, y: 0, z: -9.831}
m_LocalScale: {x: 0.3, y: 0.3, z: 0.3}
m_ConstrainProportionsScale: 0
m_Children: []
@ -19242,7 +19242,7 @@ Transform:
m_GameObject: {fileID: 1905186890}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -2.374, y: 0, z: -4.931}
m_LocalPosition: {x: -2.35, y: 0, z: -4.931}
m_LocalScale: {x: 0.3, y: 0.3, z: 0.3}
m_ConstrainProportionsScale: 0
m_Children: []
@ -19597,7 +19597,7 @@ Transform:
m_GameObject: {fileID: 1949980352}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -2.42, y: 0, z: -1.375}
m_LocalPosition: {x: -2.03, y: 0, z: -1.42}
m_LocalScale: {x: 0.3, y: 0.3, z: 0.3}
m_ConstrainProportionsScale: 0
m_Children: []
@ -19929,7 +19929,7 @@ Transform:
m_GameObject: {fileID: 1970246056}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 1.99, y: 0, z: -4.328}
m_LocalPosition: {x: 2.05, y: 0, z: -4.328}
m_LocalScale: {x: 0.3, y: 0.3, z: 0.3}
m_ConstrainProportionsScale: 0
m_Children: []
@ -20476,13 +20476,13 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2024055159}
serializedVersion: 2
m_LocalRotation: {x: 0.3620372, y: -0.16267893, z: 0.05123903, w: 0.9164274}
m_LocalPosition: {x: 29.7, y: 44.4, z: -160.97583}
m_LocalRotation: {x: 0.31600544, y: 0.18255064, z: -0.062098723, w: 0.9289563}
m_LocalPosition: {x: -20.82, y: 36.39, z: -162.95}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 42.862, y: -20.865, z: -1.867}
m_LocalEulerAnglesHint: {x: 37.574, y: 22.235, z: 0}
--- !u!1 &2026345984
GameObject:
m_ObjectHideFlags: 0
@ -20566,6 +20566,112 @@ MeshFilter:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2026345984}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &2041769183
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2041769187}
- component: {fileID: 2041769186}
- component: {fileID: 2041769185}
- component: {fileID: 2041769184}
m_Layer: 0
m_Name: Plane
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!64 &2041769184
MeshCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2041769183}
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: 5
m_Convex: 0
m_CookingOptions: 30
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &2041769185
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2041769183}
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: 2100000, guid: 87d8b3bb297bfaf47bad9d545a403a1a, type: 2}
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 &2041769186
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2041769183}
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &2041769187
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2041769183}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0.99932873, z: -0, w: 0.036635824}
m_LocalPosition: {x: -3.0236487, y: 1.6, z: -110.5}
m_LocalScale: {x: 14, y: 9, z: 9}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: -175.801, z: 0}
--- !u!1 &2043966178
GameObject:
m_ObjectHideFlags: 0
@ -21007,7 +21113,7 @@ Transform:
m_GameObject: {fileID: 2078968654}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 6.59, y: 0, z: -3.726}
m_LocalPosition: {x: 6.81, y: 0, z: -3.726}
m_LocalScale: {x: 0.3, y: 0.3, z: 0.3}
m_ConstrainProportionsScale: 0
m_Children: []
@ -22352,6 +22458,7 @@ SceneRoots:
- {fileID: 1309797243}
- {fileID: 788153997}
- {fileID: 1046758797}
- {fileID: 2041769187}
- {fileID: 1521691076}
- {fileID: 2082243942}
- {fileID: 1764941256}

View File

@ -114,7 +114,6 @@ public class PathLineAnimator : MonoBehaviour
int count = points.Count;
if (count >= 2 && Vector3.Distance(point.position, points[count - 2].position) < 0.01f)
{
// 移除中间的点A → B → A => 移除 B
points.RemoveAt(count - 2);
}
points.Add(point);

View File

@ -1,227 +1,257 @@
using System;
using UnityEngine;
/***************主要控制摄像机拖动旋转******************/
public class CameraController: MonoBehaviour
public class CameraController : MonoBehaviour
{
#region
public static CameraController Instance;
#endregion
//public Transform targetModel;//目标模型
//public Transform targetM1;
public Transform target;
// 移动速度
public float speed = 20;
// 旋转距离
public float distance_v;
public float distance_h;
// 旋转速度
public float rotation_H_speed = 1;
public float rotation_V_speed = 1;
// 平移速度
public float move_H_speed = 2;
public float move_V_speed = 2;
public float current_rotation_H; //水平旋转结果
public float current_rotation_V; //垂直旋转结果
// 旋转限制
public float maxUpAngle = 85;
public float maxDownAngle = 5;
//// 平移限制
//public float transMaxUp = 400;
//public float transMaxDown = 20;
public float moveSpeed = 2;
// 缩放限制
//在主界面的缩放范围
public float origanZoomMax= 381.9326f;
public float origanzoomMin = 158f;
private float zoomMax = 400;
private float zoomMin = 5;
private float zoomSpeed = 15;
private Vector3 mForward;
private bool IsEnableZoom = true;
public Transform HomePos;
public Transform OtherPos;
/// <summary>
/// 更换目标物
/// </summary>
/// <param name="trans"></param>
public void SetCameraRoteTarget(Transform trans)
{
target = trans;
}
private void InitZoomRange()
{
zoomMax = origanZoomMax;
zoomMin = origanzoomMin;
}
private void Start()
{
Instance = this;
InitZoomRange();
SetHomePos();
transform.LookAt(target);
}
public void SetHomePos()
{
transform.position = HomePos.transform.position;
transform.rotation = HomePos.transform.rotation;
transform.LookAt(target);
}
public void SetChePos_Tyb()//体验版里得
{
transform.localPosition = new Vector3(6.7f,2.7f,-3.25f);
transform.localEulerAngles = new Vector3(39.775f,-1.968f,-0.254f);
transform.LookAt(target);
}
public void SetChePos_Zsb()
{
transform.localPosition = new Vector3(6.6073f, 36.7f, -44.3f);
transform.LookAt(target);
}
public void SetOtherPos()
{
transform.position = OtherPos.transform.position;
transform.rotation = OtherPos.transform.rotation;
}
void Update()
{
if(target==null)return;
//if(!GameDataManager.Instance.isLoginSuccess)return;
#region
if (IsEnableZoom)
{
// 缩放
if (Input.GetAxis("Mouse ScrollWheel") != 0)
{
//获取鼠标滚轮的滑动量
float wheel = Input.GetAxis("Mouse ScrollWheel") * Time.deltaTime * zoomSpeed;
public static CameraController Instance;
#endregion
//public Transform targetModel;//目标模型
//public Transform targetM1;
public Transform target;
// 移动速度
public float speed = 20;
// 旋转距离
public float distance_v;
//改变相机的位置
//Vector3 pos = Vector3.forward* wheel;
//float y = pos.y + transform.position.y;
public float distance_h;
//y = Mathf.Clamp(y, zoomMaxDown, zoomMaxUp);
// 旋转速度
public float rotation_H_speed = 1;
//transform.position = new Vector3(transform.position.x, y, transform.position.z);
//this.transform.Translate(pos);
//print(Vector3.Distance(transform.position, targetModel.position));
Debug.Log("zoomMin" + Vector3.Distance(transform.position, target.position));
Debug.Log("zoomMax" + Vector3.Distance(transform.position, target.position));
if (Vector3.Distance(transform.position, target.position) < zoomMin && wheel > 0) return;
if (Vector3.Distance(transform.position, target.position) > zoomMax && wheel < 0) return;
mForward = target.position - Camera.main.transform.position;
transform.position += mForward * wheel;
if (Vector3.Distance(transform.position, target.position) > zoomMax)
{
transform.position = target.position + (transform.position - target.position).normalized * zoomMax;
}
if (Vector3.Distance(transform.position, target.position) < zoomMin)
{
transform.position = target.position + (transform.position - target.position).normalized * zoomMin;
}
}
}
}
public float rotation_V_speed = 1;
private void LateUpdate()
{
if(target==null)return;
// 点击 并获取点击物体
if (Input.GetMouseButtonUp(0))
{
// 前端 click() ---> 点击物体
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, 2000))
{
Debug.DrawLine(ray.origin, hit.point, Color.red, 0.5f);
//Debug.Log(hit.point);
}
}
// 平移速度
public float move_H_speed = 2;
public float move_V_speed = 2;
// 旋转
if (Input.GetMouseButton(1))
{
//控制旋转
//current_rotation_H += Input.GetAxis("Mouse X") * rotation_H_speed;
//current_rotation_V += Input.GetAxis("Mouse Y") * rotation_V_speed;
public float current_rotation_H; //水平旋转结果
//current_rotation_V = Mathf.Clamp(current_rotation_V, maxDownAngle, maxUpAngle);
public float current_rotation_V; //垂直旋转结果
//transform.localEulerAngles = new Vector3(current_rotation_V, current_rotation_H, transform.localEulerAngles.z);
// 旋转限制
public float maxUpAngle = 85;
//transform.Translate(Vector3.back * distance_h, Space.Self);
//transform.Translate(Vector3.up * distance_v, Space.World); //相对于世界坐标y轴向上
public float maxDownAngle = 5;
var mouse_x = Input.GetAxis("Mouse X");//获取鼠标X轴移动
var mouse_y = -Input.GetAxis("Mouse Y");//获取鼠标Y轴移动
//transform.LookAt(target);
//// 平移限制
//public float transMaxUp = 400;
//public float transMaxDown = 20;
public float moveSpeed = 2;
transform.RotateAround(target.transform.position, Vector3.up, mouse_x * 5);
//transform.RotateAround(targetModel.transform.position, transform.right, mouse_y * 5);
// 缩放限制
//在主界面的缩放范围
public float origanZoomMax = 381.9326f;
public float origanzoomMin = 158f;
//预设角度(当前角度加上将要增加/减少的角度)
float rotatedAngle = transform.eulerAngles.x + mouse_y * rotation_H_speed;
private float zoomMax = 400;
private float zoomMin = 5;
private float zoomSpeed = 15;
//旋转角度小于5则设置为5
if (rotatedAngle < maxDownAngle)
{
transform.RotateAround(target.position, transform.right, (mouse_y * rotation_H_speed) + (maxDownAngle - rotatedAngle));
}
else if (rotatedAngle > maxUpAngle) //旋转角度大于85则设置85
{
transform.RotateAround(target.position, transform.right, (mouse_y * rotation_H_speed) - (rotatedAngle - maxUpAngle));
}
else
{
transform.RotateAround(target.position, transform.right, mouse_y * rotation_H_speed);
}
}
private Vector3 mForward;
private bool IsEnableZoom = true;
public Transform HomePos;
public Transform OtherPos;
public float offect = 10f; // 缩放偏移量
/// <summary>
/// 更换目标物
/// </summary>
/// <param name="trans"></param>
public void SetCameraRoteTarget(Transform trans)
{
target = trans;
}
private void InitZoomRange()
{
zoomMax = origanZoomMax;
zoomMin = origanzoomMin;
}
private void Start()
{
Instance = this;
InitZoomRange();
SetHomePos();
EventManager.EndFollowPathEvent += EndFollowPathEvent;
}
private void EndFollowPathEvent(PathType pathType)
{
SetHomePos();
}
public void SetHomePos()
{
transform.position = HomePos.transform.position;
transform.rotation = HomePos.transform.rotation;
transform.LookAt(target);
// 获取当前旋转
Quaternion lookRotation = transform.rotation;
Quaternion upwardTilt = Quaternion.Euler(offect, 0, 0); // 30度向上倾斜
transform.rotation = lookRotation * upwardTilt;
}
public void SetChePos_Tyb() //体验版里得
{
transform.localPosition = new Vector3(6.7f, 2.7f, -3.25f);
transform.localEulerAngles = new Vector3(39.775f, -1.968f, -0.254f);
transform.LookAt(target);
}
public void SetChePos_Zsb()
{
transform.localPosition = new Vector3(6.6073f, 36.7f, -44.3f);
transform.LookAt(target);
}
public void SetOtherPos()
{
transform.position = OtherPos.transform.position;
transform.rotation = OtherPos.transform.rotation;
}
void Update()
{
if (target == null) return;
//if(!GameDataManager.Instance.isLoginSuccess)return;
if (IsEnableZoom)
{
// 缩放
if (Input.GetAxis("Mouse ScrollWheel") != 0)
{
//获取鼠标滚轮的滑动量
float wheel = Input.GetAxis("Mouse ScrollWheel") * Time.deltaTime * zoomSpeed;
//改变相机的位置
//Vector3 pos = Vector3.forward* wheel;
//float y = pos.y + transform.position.y;
//y = Mathf.Clamp(y, zoomMaxDown, zoomMaxUp);
//transform.position = new Vector3(transform.position.x, y, transform.position.z);
//this.transform.Translate(pos);
//print(Vector3.Distance(transform.position, targetModel.position));
Debug.Log("zoomMin" + Vector3.Distance(transform.position, target.position));
Debug.Log("zoomMax" + Vector3.Distance(transform.position, target.position));
if (Vector3.Distance(transform.position, target.position) < zoomMin && wheel > 0) return;
if (Vector3.Distance(transform.position, target.position) > zoomMax && wheel < 0) return;
mForward = target.position - Camera.main.transform.position;
transform.position += mForward * wheel;
if (Vector3.Distance(transform.position, target.position) > zoomMax)
{
transform.position = target.position + (transform.position - target.position).normalized * zoomMax;
}
if (Vector3.Distance(transform.position, target.position) < zoomMin)
{
transform.position = target.position + (transform.position - target.position).normalized * zoomMin;
}
}
}
}
private void LateUpdate()
{
if (target == null) return;
// 点击 并获取点击物体
if (Input.GetMouseButtonUp(0))
{
// 前端 click() ---> 点击物体
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, 2000))
{
Debug.DrawLine(ray.origin, hit.point, Color.red, 0.5f);
//Debug.Log(hit.point);
}
}
// 旋转
if (Input.GetMouseButton(1))
{
//控制旋转
//current_rotation_H += Input.GetAxis("Mouse X") * rotation_H_speed;
//current_rotation_V += Input.GetAxis("Mouse Y") * rotation_V_speed;
//current_rotation_V = Mathf.Clamp(current_rotation_V, maxDownAngle, maxUpAngle);
//transform.localEulerAngles = new Vector3(current_rotation_V, current_rotation_H, transform.localEulerAngles.z);
//transform.Translate(Vector3.back * distance_h, Space.Self);
//transform.Translate(Vector3.up * distance_v, Space.World); //相对于世界坐标y轴向上
var mouse_x = Input.GetAxis("Mouse X"); //获取鼠标X轴移动
var mouse_y = -Input.GetAxis("Mouse Y"); //获取鼠标Y轴移动
//transform.LookAt(target);
transform.RotateAround(target.transform.position, Vector3.up, mouse_x * 5);
//transform.RotateAround(targetModel.transform.position, transform.right, mouse_y * 5);
//预设角度(当前角度加上将要增加/减少的角度)
float rotatedAngle = transform.eulerAngles.x + mouse_y * rotation_H_speed;
//旋转角度小于5则设置为5
if (rotatedAngle < maxDownAngle)
{
transform.RotateAround(target.position, transform.right,
(mouse_y * rotation_H_speed) + (maxDownAngle - rotatedAngle));
}
else if (rotatedAngle > maxUpAngle) //旋转角度大于85则设置85
{
transform.RotateAround(target.position, transform.right,
(mouse_y * rotation_H_speed) - (rotatedAngle - maxUpAngle));
}
else
{
transform.RotateAround(target.position, transform.right, mouse_y * rotation_H_speed);
}
}
// 平移(按住鼠标中键)
if (Input.GetMouseButton(2)) // 鼠标中键
{
Vector3 pos = new Vector3(-Input.GetAxis("Mouse X") * move_H_speed, -Input.GetAxis("Mouse Y") * move_V_speed, 0f);
float y = pos.y + transform.position.y;
if (y > 0) // 平移的约束范围可以根据需要调整
{
transform.Translate(pos, Space.Self);
}
}
// 平移(按住鼠标中键)
if (Input.GetMouseButton(2)) // 鼠标中键
{
Vector3 pos = new Vector3(-Input.GetAxis("Mouse X") * move_H_speed,
-Input.GetAxis("Mouse Y") * move_V_speed, 0f);
float y = pos.y + transform.position.y;
if (y > 0) // 平移的约束范围可以根据需要调整
{
transform.Translate(pos, Space.Self);
}
}
}
}
public float CheckAngle(float value)
{
float angle = value - 180;
public float CheckAngle(float value)
{
float angle = value - 180;
if (angle > 0)
return angle - 180;
if (angle > 0)
return angle - 180;
return angle + 180;
}
return angle + 180;
}
private static float ClampAngle(float angle, float min, float max)
{
if (angle < -360)
angle += 360;
if (angle > 360)
angle -= 360;
return Mathf.Clamp(angle, min, max);
}
}
private static float ClampAngle(float angle, float min, float max)
{
if (angle < -360)
angle += 360;
if (angle > 360)
angle -= 360;
return Mathf.Clamp(angle, min, max);
}
private void OnDestroy()
{
EventManager.EndFollowPathEvent -= EndFollowPathEvent;
}
}

View File

@ -1,14 +1,15 @@
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class PathFinder
{
public static List<MapGraph.Node> FindPath(MapGraph.Node start, MapGraph.Node goal)
{
return FindPathInternal(start, goal, new HashSet<MapGraph.Node>());
return FindPathInternal(start, goal, new HashSet<MapGraph.Node>(), new HashSet<MapGraph.Node>(), false);
}
private static List<MapGraph.Node> FindPathInternal(MapGraph.Node start, MapGraph.Node goal, HashSet<MapGraph.Node> temporarilyAllowed)
private static List<MapGraph.Node> FindPathInternal(MapGraph.Node start, MapGraph.Node goal, HashSet<MapGraph.Node> temporarilyAllowed, HashSet<MapGraph.Node> visitedNodes, bool allowVisited)
{
// 优先队列:按 fScore 排序
var openSet = new PriorityQueue<MapGraph.Node>();
@ -42,6 +43,11 @@ public class PathFinder
if (!edge.target.isReachable && !temporarilyAllowed.Contains(edge.target))
continue;
// 检查是否允许访问已访问节点
bool isVisited = visitedNodes.Contains(edge.target);
if (isVisited && !allowVisited)
continue;
float tentativeG = gScore[current] + edge.cost;
// 如果没访问过目标节点,或找到更短的路径
@ -62,11 +68,10 @@ public class PathFinder
}
}
// 找不到路径,返回空列表(比返回 null 更安全)
// 找不到路径,返回空列表
return new List<MapGraph.Node>();
}
public static List<MapGraph.Node> FindPathThroughNodes(
List<MapGraph.Node> mustPassNodes,
List<MapGraph.Node> mustAvoidNodes,
@ -84,49 +89,124 @@ public class PathFinder
foreach (var node in mustAvoidNodes)
node.isReachable = false;
List<MapGraph.Node> finalPath = new List<MapGraph.Node>();
// 从第一个必经点开始,依次连接后续必经点
for (int i = 0; i < mustPassNodes.Count - 1; i++)
// 尝试多次寻找路径,每次使用不同的约束条件
for (int attempt = 0; attempt < 3; attempt++)
{
var start = mustPassNodes[i];
var end = mustPassNodes[i + 1];
List<MapGraph.Node> finalPath = new List<MapGraph.Node>();
HashSet<MapGraph.Node> visitedNodes = new HashSet<MapGraph.Node>();
// 尝试绕过不可达点
var path = FindPathInternal(start, end, new HashSet<MapGraph.Node>());
// 添加所有必经点到已访问集合,但允许起点和终点被访问
for (int i = 1; i < mustPassNodes.Count - 1; i++)
visitedNodes.Add(mustPassNodes[i]);
// 如果失败,允许穿越 mustAvoid 节点
if (path == null)
bool pathFound = true;
// 从第一个必经点开始,依次连接后续必经点
for (int i = 0; i < mustPassNodes.Count - 1; i++)
{
Debug.LogWarning($"尝试避开 mustAvoid 节点失败,强制允许通行");
var start = mustPassNodes[i];
var end = mustPassNodes[i + 1];
var temporarilyAllowed = new HashSet<MapGraph.Node>(mustAvoidNodes);
path = FindPathInternal(start, end, temporarilyAllowed);
// 移除当前起点和终点的访问限制
visitedNodes.Remove(start);
visitedNodes.Remove(end);
if (path != null)
// 根据尝试次数调整搜索策略
bool allowVisitedNodes = attempt > 0; // 第一次尝试不允许访问已访问节点,后续尝试允许
// 尝试寻找路径
var path = FindPathInternal(start, end, new HashSet<MapGraph.Node>(), visitedNodes, allowVisitedNodes);
if (path.Count == 0)
{
// 记录穿过了哪些 mustAvoid
foreach (var node in path)
{
if (mustAvoidNodes.Contains(node) && !passedForbiddenNodes.Contains(node))
passedForbiddenNodes.Add(node);
}
pathFound = false;
break;
}
else
// 检查路径是否有重复节点(除了起点和终点)
bool hasDuplicates = HasDuplicateNodes(path, start, end);
// 如果有重复节点且不是最后一次尝试,放弃当前路径
if (hasDuplicates && attempt < 2)
{
Debug.LogError($"路径规划失败:{start.id} 到 {end.id} 无法连接");
return null;
pathFound = false;
break;
}
// 记录穿过了哪些 mustAvoid 节点
foreach (var node in path)
{
if (mustAvoidNodes.Contains(node) && !passedForbiddenNodes.Contains(node))
passedForbiddenNodes.Add(node);
}
// 合并路径(去掉重复的起点)
if (finalPath.Count > 0 && path.Count > 0 && finalPath[finalPath.Count - 1] == path[0])
path.RemoveAt(0);
// 添加到最终路径并更新已访问节点
finalPath.AddRange(path);
foreach (var node in path)
if (node != start && node != end)
visitedNodes.Add(node);
}
// 如果找到路径且没有重复节点,返回
if (pathFound && !HasDuplicateNodes(finalPath, mustPassNodes[0], mustPassNodes[mustPassNodes.Count - 1]))
return finalPath;
}
// 如果多次尝试后仍无法找到无重复节点的路径,返回最后一次尝试的结果
Debug.LogWarning("无法找到完全无重复节点的路径,返回优化后的路径");
List<MapGraph.Node> finalAttemptPath = FindPathInternal(mustPassNodes[0], mustPassNodes[mustPassNodes.Count - 1],
new HashSet<MapGraph.Node>(mustAvoidNodes),
new HashSet<MapGraph.Node>(), true);
return RemoveLoops(finalAttemptPath);
}
// 检查路径是否有重复节点(除了可选的 start 和 end 节点)
private static bool HasDuplicateNodes(List<MapGraph.Node> path, MapGraph.Node start, MapGraph.Node end)
{
var visited = new HashSet<MapGraph.Node>();
foreach (var node in path)
{
if (node == start || node == end)
continue; // 允许起点和终点重复
if (visited.Contains(node))
return true;
visited.Add(node);
}
return false;
}
// 移除路径中的环(重复节点)
private static List<MapGraph.Node> RemoveLoops(List<MapGraph.Node> path)
{
var newPath = new List<MapGraph.Node>();
var visited = new HashSet<MapGraph.Node>();
foreach (var node in path)
{
if (visited.Contains(node))
{
// 发现环,回溯到上一次出现该节点的位置
while (newPath.Count > 0 && newPath.Last() != node)
{
visited.Remove(newPath.Last());
newPath.RemoveAt(newPath.Count - 1);
}
}
// 合并路径(去掉重复的中间点)
if (finalPath.Count > 0 && finalPath[finalPath.Count - 1] == path[0])
path.RemoveAt(0);
finalPath.AddRange(path);
}
return finalPath;
}
else
{
visited.Add(node);
newPath.Add(node);
}
}
return newPath;
}
private static float Heuristic(MapGraph.Node a, MapGraph.Node b)
{
@ -135,15 +215,12 @@ public class PathFinder
private static List<MapGraph.Node> ReconstructPath(Dictionary<MapGraph.Node, MapGraph.Node> cameFrom, MapGraph.Node current)
{
List<MapGraph.Node> totalPath = new List<MapGraph.Node> { current };
while (cameFrom.ContainsKey(current))
{
Debug.Log($"current:{current.camera_id}");
current = cameFrom[current];
Debug.Log($"current1:{current.camera_id}");
totalPath.Insert(0, current);
}
return totalPath;
}
}
}

View File

@ -307,12 +307,37 @@ namespace QFramework.Example
Real_time_car.gameObject.SetActive(true);
Real_time_car.transform.localPosition = new Vector3(-752f, 86f, 0);
if (QueryMySqlManager.Instance == null) return;
int totalCount = QueryMySqlManager.Instance.VehiclesResultList.Count;
int studentCount = 0;
int teatherCount = 0;
int visitorCount = 0;
int unknowCount = 0;
for (int i = 0; i < QueryMySqlManager.Instance.VehiclesResultList.Count; i++)
{
if (QueryMySqlManager.Instance.VehiclesResultList[i].role == <><D1A7>")
{
studentCount += 1;
}
else if (QueryMySqlManager.Instance.VehiclesResultList[i].role == "<22><>ʦ")
{
teatherCount += 1;
}
else if (QueryMySqlManager.Instance.VehiclesResultList[i].role == "<22>ÿ<EFBFBD>")
{
visitorCount += 1;
}
else
{
unknowCount += 1;
}
}
All_Car.transform.Find("Count").GetComponent<Text>().text = QueryMySqlManager.Instance.VehiclesResultList.Count.ToString();
Student.transform.Find("Count").GetComponent<Text>().text = QueryMySqlManager.Instance.VehiclesResultList.Count.ToString();
Teach.transform.Find("Count").GetComponent<Text>().text = QueryMySqlManager.Instance.VehiclesResultList.Count.ToString();
Visitor.transform.Find("Count").GetComponent<Text>().text = QueryMySqlManager.Instance.VehiclesResultList.Count.ToString();
Unknown.transform.Find("Count").GetComponent<Text>().text = QueryMySqlManager.Instance.VehiclesResultList.Count.ToString();
All_Car.transform.Find("Count").GetComponent<Text>().text = totalCount.ToString();
Student.transform.Find("Count").GetComponent<Text>().text = studentCount.ToString();
Teach.transform.Find("Count").GetComponent<Text>().text = teatherCount.ToString();
Visitor.transform.Find("Count").GetComponent<Text>().text = visitorCount.ToString();
Unknown.transform.Find("Count").GetComponent<Text>().text = unknowCount.ToString();
}
protected override void OnHide()

View File

@ -39,7 +39,7 @@ namespace QFramework.Example
{
EventManager.TriggerStartFollowPathEvent(PathType.Person);
});
}
}
private void Update()
{
@ -301,11 +301,36 @@ namespace QFramework.Example
if (QueryMySqlManager.Instance == null) return ;
All_Person.transform.Find("Count").GetComponent<Text>().text = QueryMySqlManager.Instance.PersonResultList.Count.ToString();
Student.transform.Find("Count").GetComponent<Text>().text = QueryMySqlManager.Instance.PersonResultList.Count.ToString();
Teach.transform.Find("Count").GetComponent<Text>().text = QueryMySqlManager.Instance.PersonResultList.Count.ToString();
Visitor.transform.Find("Count").GetComponent<Text>().text = QueryMySqlManager.Instance.PersonResultList.Count.ToString();
Unknown.transform.Find("Count").GetComponent<Text>().text = QueryMySqlManager.Instance.PersonResultList.Count.ToString();
int totalCount = QueryMySqlManager.Instance.PersonResultList.Count;
int studentCount = 0;
int teatherCount = 0;
int visitorCount = 0;
int unknowCount = 0;
for (int i = 0; i < QueryMySqlManager.Instance.PersonResultList.Count; i++)
{
if (QueryMySqlManager.Instance.PersonResultList[i].role == "学生")
{
studentCount += 1;
}
else if (QueryMySqlManager.Instance.PersonResultList[i].role == "教师")
{
teatherCount += 1;
}
else if (QueryMySqlManager.Instance.PersonResultList[i].role == "访客")
{
visitorCount += 1;
}
else
{
unknowCount += 1;
}
}
All_Person.transform.Find("Count").GetComponent<Text>().text = totalCount.ToString();
Student.transform.Find("Count").GetComponent<Text>().text = studentCount.ToString();
Teach.transform.Find("Count").GetComponent<Text>().text = teatherCount.ToString();
Visitor.transform.Find("Count").GetComponent<Text>().text = visitorCount.ToString();
Unknown.transform.Find("Count").GetComponent<Text>().text = unknowCount.ToString();