提交日志-20240704-1046:

1、更新了本地配置的堆场、相机、皮带秤数据结构,现在可以根据不同企业id进行配置;
2、优化了路径漫游的可配置内容,现在可以单独对每个节点速度进行配置;
This commit is contained in:
Afeijia 2024-07-04 10:45:54 +08:00
parent feda88e06e
commit d699e335df
7 changed files with 115 additions and 61 deletions

View File

@ -61,10 +61,6 @@ public class CameraRoamManager : Singleton<CameraRoamManager>
/// </summary> /// </summary>
public Quaternion m_Rotation; public Quaternion m_Rotation;
/// <summary> /// <summary>
/// ÂþÓÎËÙ¶È
/// </summary>
public float RoamingSpeed = 10;
/// <summary>
/// Dopath参数 /// Dopath参数
/// </summary> /// </summary>
[Range(0, 1)] [Range(0, 1)]
@ -122,12 +118,15 @@ public class CameraRoamManager : Singleton<CameraRoamManager>
/// 循环起始点 /// 循环起始点
/// </summary> /// </summary>
public int LoopStartPoint = 3; public int LoopStartPoint = 3;
///// <summary> /// <summary>
///// ÂþÓÎËÙ¶È /// 是否使用锚点配置速度
///// </summary> /// </summary>
//[Range(0,100)] public bool UseAnchorSpeed = false;
//public float RoamingSpeed = 10; /// <summary>
/// 漫游速度
/// </summary>
[Range(0, 100)]
public float RoamingSpeed = 10;
#endregion #endregion
@ -319,7 +318,7 @@ public class CameraRoamManager : Singleton<CameraRoamManager>
} }
_to += _t; _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; TargetCamera.position = _rt_pos;
_at_point = TargetCamera.position == _Anchor_Point[_Next_Index].Position; _at_point = TargetCamera.position == _Anchor_Point[_Next_Index].Position;

View File

@ -10,6 +10,7 @@ public class RoamingAnchorEditor : Editor
SerializedProperty LookTransform; SerializedProperty LookTransform;
SerializedProperty LookPoint; SerializedProperty LookPoint;
SerializedProperty LookType; SerializedProperty LookType;
SerializedProperty Speed;
private void OnEnable() private void OnEnable()
{ {
@ -18,6 +19,7 @@ public class RoamingAnchorEditor : Editor
LookTransform = serializedObject.FindProperty("LookTransform"); LookTransform = serializedObject.FindProperty("LookTransform");
LookPoint = serializedObject.FindProperty("LookPoint"); LookPoint = serializedObject.FindProperty("LookPoint");
LookType = serializedObject.FindProperty("LookType"); LookType = serializedObject.FindProperty("LookType");
Speed = serializedObject.FindProperty("Speed");
} }
public override void OnInspectorGUI() public override void OnInspectorGUI()
@ -40,6 +42,8 @@ public class RoamingAnchorEditor : Editor
break; break;
} }
EditorGUILayout.PropertyField(Speed);
serializedObject.ApplyModifiedProperties(); serializedObject.ApplyModifiedProperties();
} }
} }

View File

@ -21,11 +21,22 @@ public class RoamingAnchor : MonoBehaviour
/// 路径用时 /// 路径用时
/// </summary> /// </summary>
public float Duration; public float Duration;
/// <summary>
/// 视角跟随Transform
/// </summary>
public Transform LookTransform; public Transform LookTransform;
/// <summary>
/// 视角跟随三维坐标
/// </summary>
public Vector3 LookPoint; public Vector3 LookPoint;
/// <summary>
/// 相机经过该路径锚点时的视角控制方式
/// </summary>
public LookType LookType = LookType.PATH; public LookType LookType = LookType.PATH;
/// <summary>
/// 相机速度
/// </summary>
public float Speed = 10;
//public void Init() //public void Init()
// { // {
// Position = transform.position; // Position = transform.position;

View File

@ -8,6 +8,13 @@ using Newtonsoft.Json.Linq;
using Competition.Mysql.Model; using Competition.Mysql.Model;
using static ZenFulcrum.EmbeddedBrowser.Browser; using static ZenFulcrum.EmbeddedBrowser.Browser;
public class Configure
{
public string MONITOR_ID { get; set; }
public Dictionary<string, string> DATA { get;set; }
}
public class ApiManager : Singleton<ApiManager> public class ApiManager : Singleton<ApiManager>
{ {
/// <summary> /// <summary>
@ -83,6 +90,18 @@ public class ApiManager : Singleton<ApiManager>
// } // }
//})); //}));
#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"); var _api_dic_url = Path.Combine(Application.streamingAssetsPath, "configure_api.json");
StartCoroutine(RequestBase.Get(_api_dic_url, (_data, _error) => StartCoroutine(RequestBase.Get(_api_dic_url, (_data, _error) =>
{ {
@ -100,14 +119,20 @@ public class ApiManager : Singleton<ApiManager>
var _cam_dic_url = Path.Combine(Application.streamingAssetsPath, "configure_camera.json"); var _cam_dic_url = Path.Combine(Application.streamingAssetsPath, "configure_camera.json");
StartCoroutine(RequestBase.Get(_cam_dic_url, (_data, _error) => StartCoroutine(RequestBase.Get(_cam_dic_url, (_data, _error) =>
{ {
if (_error != null) if (_error != null)
{ {
Debug.Log($"<color=#ff0000> {_error} </color>"); Debug.Log($"<color=#ff0000> {_error} </color>");
} }
else else
{ {
Debug.Log("读取相机文件完成"); Debug.Log("读取相机文件完成");
CameraDic = JsonConvert.DeserializeObject<Dictionary<string, string>>(_data); var _datas = JsonConvert.DeserializeObject<List<Configure>>(_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<Dictionary<string, string>>(_data);
} }
})); }));
@ -120,8 +145,15 @@ public class ApiManager : Singleton<ApiManager>
} }
else else
{ {
Debug.Log("读取相机文件完成"); Debug.Log("读取堆场文件完成");
YardDic = JsonConvert.DeserializeObject<Dictionary<string, string>>(_data);
//YardDic = JsonConvert.DeserializeObject<Dictionary<string, string>>(_data);
var _datas = JsonConvert.DeserializeObject<List<Configure>>(_data);
var _yard_data = _datas.Find(x => x.MONITOR_ID == CallForTest.instance.MONITOR_ID);
if (_yard_data != null)
{
YardDic = _yard_data.DATA;
}
} }
})); }));
//获取摄像机列表 //获取摄像机列表

View File

@ -1,8 +1,6 @@
{ [
"01": "YARD000226", {
"02": "YARD000227", "MONITOR_ID": "CNMAW350015",
"03": "YARD000228", "DATA": {}
"04": "YARD000229", }
"05": "YARD000230", ]
"06": "YARD000231"
}

View File

@ -1,28 +1,33 @@
{ [
"01": "Camera000100", {
"02": "Camera000101", "MONITOR_ID": "CNMAW350015",
"03": "Camera000102", "DATA": {
"04": "Camera000103", "01": "Camera000100",
"05": "Camera000104", "02": "Camera000101",
"06": "Camera000105", "03": "Camera000102",
"07": "Camera000106", "04": "Camera000103",
"08": "Camera000107", "05": "Camera000104",
"09": "", "06": "Camera000105",
"10": "", "07": "Camera000106",
"11": "", "08": "Camera000107",
"12": "", "09": "",
"13": "", "10": "",
"14": "", "11": "",
"15": "", "12": "",
"16": "", "13": "",
"17": "", "14": "",
"18": "", "15": "",
"19": "", "16": "",
"20": "", "17": "",
"21": "", "18": "",
"22": "", "19": "",
"23": "", "20": "",
"24": "", "21": "",
"25": "", "22": "",
"26": "" "23": "",
} "24": "",
"25": "",
"26": ""
}
}
]

View File

@ -1,8 +1,13 @@
{ [
"01": "YARD000226", {
"02": "YARD000227", "MONITOR_ID": "CNMAW350015",
"03": "YARD000228", "DATA": {
"04": "YARD000229", "01": "YARD000226",
"05": "YARD000230", "02": "YARD000227",
"06": "YARD000231" "03": "YARD000228",
} "04": "YARD000229",
"05": "YARD000230",
"06": "YARD000231"
}
}
]