From d699e335dfcacb9f7a39609e73025ba258330111 Mon Sep 17 00:00:00 2001 From: Afeijia Date: Thu, 4 Jul 2024 10:45:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=97=A5=E5=BF=97-20240704-1?= =?UTF-8?q?046=EF=BC=9A=201=E3=80=81=E6=9B=B4=E6=96=B0=E4=BA=86=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E9=85=8D=E7=BD=AE=E7=9A=84=E5=A0=86=E5=9C=BA=E3=80=81?= =?UTF-8?q?=E7=9B=B8=E6=9C=BA=E3=80=81=E7=9A=AE=E5=B8=A6=E7=A7=A4=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=BB=93=E6=9E=84=EF=BC=8C=E7=8E=B0=E5=9C=A8=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E6=A0=B9=E6=8D=AE=E4=B8=8D=E5=90=8C=E4=BC=81=E4=B8=9A?= =?UTF-8?q?id=E8=BF=9B=E8=A1=8C=E9=85=8D=E7=BD=AE=EF=BC=9B=202=E3=80=81?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BA=86=E8=B7=AF=E5=BE=84=E6=BC=AB=E6=B8=B8?= =?UTF-8?q?=E7=9A=84=E5=8F=AF=E9=85=8D=E7=BD=AE=E5=86=85=E5=AE=B9=EF=BC=8C?= =?UTF-8?q?=E7=8E=B0=E5=9C=A8=E5=8F=AF=E4=BB=A5=E5=8D=95=E7=8B=AC=E5=AF=B9?= =?UTF-8?q?=E6=AF=8F=E4=B8=AA=E8=8A=82=E7=82=B9=E9=80=9F=E5=BA=A6=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E9=85=8D=E7=BD=AE=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scripts/wj/Camera/CameraRoamManager.cs | 21 +++---- .../wj/Camera/Editor/RoamingAnchorEditor.cs | 4 ++ .../Assets/Scripts/wj/Camera/RoamingAnchor.cs | 15 ++++- .../Assets/Scripts/wj/Manager/ApiManager.cs | 40 ++++++++++-- .../StreamingAssets/configure_belt_scale.json | 14 ++--- .../StreamingAssets/configure_camera.json | 61 ++++++++++--------- .../StreamingAssets/configure_yard.json | 21 ++++--- 7 files changed, 115 insertions(+), 61 deletions(-) diff --git a/BulkCargo_UnityProject/Assets/Scripts/wj/Camera/CameraRoamManager.cs b/BulkCargo_UnityProject/Assets/Scripts/wj/Camera/CameraRoamManager.cs index 1d2bbbeb..55017d34 100644 --- a/BulkCargo_UnityProject/Assets/Scripts/wj/Camera/CameraRoamManager.cs +++ b/BulkCargo_UnityProject/Assets/Scripts/wj/Camera/CameraRoamManager.cs @@ -61,10 +61,6 @@ public class CameraRoamManager : Singleton /// public Quaternion m_Rotation; /// - /// 漫游速度 - /// - public float RoamingSpeed = 10; - /// /// Dopath参数 /// [Range(0, 1)] @@ -122,12 +118,15 @@ public class CameraRoamManager : Singleton /// 循环起始点 /// public int LoopStartPoint = 3; - ///// - ///// 漫游速度 - ///// - //[Range(0,100)] - //public float RoamingSpeed = 10; - + /// + /// 是否使用锚点配置速度 + /// + public bool UseAnchorSpeed = false; + /// + /// 漫游速度 + /// + [Range(0, 100)] + public float RoamingSpeed = 10; #endregion @@ -319,7 +318,7 @@ public class CameraRoamManager : Singleton } _to += _t; - _rt_pos = Lerp(_pos, _Anchor_Point[_Next_Index].Position, _to / Vector3.Distance(_pos, _Anchor_Point[_Next_Index].Position) * RoamingSpeed); + _rt_pos = Lerp(_pos, _Anchor_Point[_Next_Index].Position, _to / Vector3.Distance(_pos, _Anchor_Point[_Next_Index].Position) * (UseAnchorSpeed ? _Anchor_Point[_Next_Index].Speed : RoamingSpeed)); TargetCamera.position = _rt_pos; _at_point = TargetCamera.position == _Anchor_Point[_Next_Index].Position; diff --git a/BulkCargo_UnityProject/Assets/Scripts/wj/Camera/Editor/RoamingAnchorEditor.cs b/BulkCargo_UnityProject/Assets/Scripts/wj/Camera/Editor/RoamingAnchorEditor.cs index 41548ca7..030addbd 100644 --- a/BulkCargo_UnityProject/Assets/Scripts/wj/Camera/Editor/RoamingAnchorEditor.cs +++ b/BulkCargo_UnityProject/Assets/Scripts/wj/Camera/Editor/RoamingAnchorEditor.cs @@ -10,6 +10,7 @@ public class RoamingAnchorEditor : Editor SerializedProperty LookTransform; SerializedProperty LookPoint; SerializedProperty LookType; + SerializedProperty Speed; private void OnEnable() { @@ -18,6 +19,7 @@ public class RoamingAnchorEditor : Editor LookTransform = serializedObject.FindProperty("LookTransform"); LookPoint = serializedObject.FindProperty("LookPoint"); LookType = serializedObject.FindProperty("LookType"); + Speed = serializedObject.FindProperty("Speed"); } public override void OnInspectorGUI() @@ -40,6 +42,8 @@ public class RoamingAnchorEditor : Editor break; } + EditorGUILayout.PropertyField(Speed); + serializedObject.ApplyModifiedProperties(); } } diff --git a/BulkCargo_UnityProject/Assets/Scripts/wj/Camera/RoamingAnchor.cs b/BulkCargo_UnityProject/Assets/Scripts/wj/Camera/RoamingAnchor.cs index 66b7bdbe..a4484f94 100644 --- a/BulkCargo_UnityProject/Assets/Scripts/wj/Camera/RoamingAnchor.cs +++ b/BulkCargo_UnityProject/Assets/Scripts/wj/Camera/RoamingAnchor.cs @@ -21,11 +21,22 @@ public class RoamingAnchor : MonoBehaviour /// 路径用时 /// public float Duration; - + /// + /// 视角跟随Transform + /// public Transform LookTransform; + /// + /// 视角跟随三维坐标 + /// public Vector3 LookPoint; - + /// + /// 相机经过该路径锚点时的视角控制方式 + /// public LookType LookType = LookType.PATH; + /// + /// 相机速度 + /// + public float Speed = 10; //public void Init() // { // Position = transform.position; diff --git a/BulkCargo_UnityProject/Assets/Scripts/wj/Manager/ApiManager.cs b/BulkCargo_UnityProject/Assets/Scripts/wj/Manager/ApiManager.cs index 1ea00191..6894798b 100644 --- a/BulkCargo_UnityProject/Assets/Scripts/wj/Manager/ApiManager.cs +++ b/BulkCargo_UnityProject/Assets/Scripts/wj/Manager/ApiManager.cs @@ -8,6 +8,13 @@ using Newtonsoft.Json.Linq; using Competition.Mysql.Model; using static ZenFulcrum.EmbeddedBrowser.Browser; +public class Configure +{ + public string MONITOR_ID { get; set; } + + public Dictionary DATA { get;set; } +} + public class ApiManager : Singleton { /// @@ -83,6 +90,18 @@ public class ApiManager : Singleton // } //})); +#if UNITY_EDITOR + if (CallForTest.instance != null) + { + if (string.IsNullOrEmpty(CallForTest.instance.MONITOR_ID)) + { + //编辑器测试 + CallForTest.instance.MONITOR_ID = "CNMAW350015"; + } + } +#endif + + var _api_dic_url = Path.Combine(Application.streamingAssetsPath, "configure_api.json"); StartCoroutine(RequestBase.Get(_api_dic_url, (_data, _error) => { @@ -100,14 +119,20 @@ public class ApiManager : Singleton var _cam_dic_url = Path.Combine(Application.streamingAssetsPath, "configure_camera.json"); StartCoroutine(RequestBase.Get(_cam_dic_url, (_data, _error) => { - if (_error != null) + if (_error != null) { Debug.Log($" {_error} "); } else { Debug.Log("读取相机文件完成"); - CameraDic = JsonConvert.DeserializeObject>(_data); + var _datas = JsonConvert.DeserializeObject>(_data); + var _camera_data = _datas.Find(x => x.MONITOR_ID == CallForTest.instance.MONITOR_ID); + if (_camera_data != null) + { + CameraDic = _camera_data.DATA; + } + //CameraDic = JsonConvert.DeserializeObject>(_data); } })); @@ -120,8 +145,15 @@ public class ApiManager : Singleton } else { - Debug.Log("读取相机文件完成"); - YardDic = JsonConvert.DeserializeObject>(_data); + Debug.Log("读取堆场文件完成"); + + //YardDic = JsonConvert.DeserializeObject>(_data); + var _datas = JsonConvert.DeserializeObject>(_data); + var _yard_data = _datas.Find(x => x.MONITOR_ID == CallForTest.instance.MONITOR_ID); + if (_yard_data != null) + { + YardDic = _yard_data.DATA; + } } })); //获取摄像机列表 diff --git a/BulkCargo_UnityProject/Assets/StreamingAssets/configure_belt_scale.json b/BulkCargo_UnityProject/Assets/StreamingAssets/configure_belt_scale.json index 34966e24..345538de 100644 --- a/BulkCargo_UnityProject/Assets/StreamingAssets/configure_belt_scale.json +++ b/BulkCargo_UnityProject/Assets/StreamingAssets/configure_belt_scale.json @@ -1,8 +1,6 @@ -{ - "01": "YARD000226", - "02": "YARD000227", - "03": "YARD000228", - "04": "YARD000229", - "05": "YARD000230", - "06": "YARD000231" -} \ No newline at end of file +[ + { + "MONITOR_ID": "CNMAW350015", + "DATA": {} + } +] \ No newline at end of file diff --git a/BulkCargo_UnityProject/Assets/StreamingAssets/configure_camera.json b/BulkCargo_UnityProject/Assets/StreamingAssets/configure_camera.json index 8a628346..bce3fd1b 100644 --- a/BulkCargo_UnityProject/Assets/StreamingAssets/configure_camera.json +++ b/BulkCargo_UnityProject/Assets/StreamingAssets/configure_camera.json @@ -1,28 +1,33 @@ -{ - "01": "Camera000100", - "02": "Camera000101", - "03": "Camera000102", - "04": "Camera000103", - "05": "Camera000104", - "06": "Camera000105", - "07": "Camera000106", - "08": "Camera000107", - "09": "", - "10": "", - "11": "", - "12": "", - "13": "", - "14": "", - "15": "", - "16": "", - "17": "", - "18": "", - "19": "", - "20": "", - "21": "", - "22": "", - "23": "", - "24": "", - "25": "", - "26": "" -} \ No newline at end of file +[ + { + "MONITOR_ID": "CNMAW350015", + "DATA": { + "01": "Camera000100", + "02": "Camera000101", + "03": "Camera000102", + "04": "Camera000103", + "05": "Camera000104", + "06": "Camera000105", + "07": "Camera000106", + "08": "Camera000107", + "09": "", + "10": "", + "11": "", + "12": "", + "13": "", + "14": "", + "15": "", + "16": "", + "17": "", + "18": "", + "19": "", + "20": "", + "21": "", + "22": "", + "23": "", + "24": "", + "25": "", + "26": "" + } + } +] \ No newline at end of file diff --git a/BulkCargo_UnityProject/Assets/StreamingAssets/configure_yard.json b/BulkCargo_UnityProject/Assets/StreamingAssets/configure_yard.json index 34966e24..3a353f6d 100644 --- a/BulkCargo_UnityProject/Assets/StreamingAssets/configure_yard.json +++ b/BulkCargo_UnityProject/Assets/StreamingAssets/configure_yard.json @@ -1,8 +1,13 @@ -{ - "01": "YARD000226", - "02": "YARD000227", - "03": "YARD000228", - "04": "YARD000229", - "05": "YARD000230", - "06": "YARD000231" -} \ No newline at end of file +[ + { + "MONITOR_ID": "CNMAW350015", + "DATA": { + "01": "YARD000226", + "02": "YARD000227", + "03": "YARD000228", + "04": "YARD000229", + "05": "YARD000230", + "06": "YARD000231" + } + } +] \ No newline at end of file